Skip to content

feat: show locks #14004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 13, 2023
Merged

feat: show locks #14004

merged 5 commits into from
Dec 13, 2023

Conversation

zhyass
Copy link
Member

@zhyass zhyass commented Dec 13, 2023

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

SHOW LOCKS [IN ACCOUNT] [WHERE expr]
mysql> show locks in account;
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
| table_id | revision | type  | status  | user | node                   | query_id                             | created_on                 | acquired_on                | extra_info |
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
|       57 |     4517 | TABLE | HOLDING | root | xzi6pRbLUYasuA9QFB36m6 | d7989971-d5ec-4764-8e37-afe38ebc13e2 | 2023-12-13 09:56:47.295684 | 2023-12-13 09:56:47.310805 |            |
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
1 row in set (0.02 sec)
Read 2 rows, 360.00 B in 0.013 sec., 153.14 rows/sec., 26.92 KiB/sec.

mysql> show locks;
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
| table_id | revision | type  | status  | user | node                   | query_id                             | created_on                 | acquired_on                | extra_info |
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
|       57 |     4517 | TABLE | HOLDING | root | xzi6pRbLUYasuA9QFB36m6 | d7989971-d5ec-4764-8e37-afe38ebc13e2 | 2023-12-13 09:56:47.295684 | 2023-12-13 09:56:47.310805 |            |
|       57 |     4521 | TABLE | WAITING | zzq  | xzi6pRbLUYasuA9QFB36m6 | 4bc78044-d4fc-4fe1-a5c5-ff6ab1e3e372 | 2023-12-13 09:56:48.419774 | NULL                       |            |
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
2 rows in set (0.02 sec)
Read 2 rows, 360.00 B in 0.012 sec., 166.76 rows/sec., 29.31 KiB/sec.

mysql> show locks where status = 'HOLDING';
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
| table_id | revision | type  | status  | user | node                   | query_id                             | created_on                 | acquired_on                | extra_info |
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
|       57 |     4517 | TABLE | HOLDING | root | xzi6pRbLUYasuA9QFB36m6 | d7989971-d5ec-4764-8e37-afe38ebc13e2 | 2023-12-13 09:56:47.295684 | 2023-12-13 09:56:47.310805 |            |
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
1 row in set (0.02 sec)
Read 2 rows, 360.00 B in 0.014 sec., 142.77 rows/sec., 25.10 KiB/sec.

mysql> select * from system.locks;
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
| table_id | revision | type  | status  | user | node                   | query_id                             | created_on                 | acquired_on                | extra_info |
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
|       57 |     4517 | TABLE | HOLDING | root | xzi6pRbLUYasuA9QFB36m6 | d7989971-d5ec-4764-8e37-afe38ebc13e2 | 2023-12-13 09:56:47.295684 | 2023-12-13 09:56:47.310805 |            |
|       57 |     4521 | TABLE | WAITING | zzq  | xzi6pRbLUYasuA9QFB36m6 | 4bc78044-d4fc-4fe1-a5c5-ff6ab1e3e372 | 2023-12-13 09:56:48.419774 | NULL                       |            |
+----------+----------+-------+---------+------+------------------------+--------------------------------------+----------------------------+----------------------------+------------+
2 rows in set (0.02 sec)
Read 2 rows, 360.00 B in 0.010 sec., 199.56 rows/sec., 35.08 KiB/sec.
  • Closes #issue

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

This change is Reviewable

@zhyass zhyass changed the title Feat stream feat: show locks Dec 13, 2023
@databendlabs databendlabs deleted a comment from github-actions bot Dec 13, 2023
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Dec 13, 2023
@BohuTANG
Copy link
Member

Also need sql logic tests for this feature, it will be useful as the unit test.

Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 15 files at r1, 1 of 20 files at r2.
Reviewable status: 4 of 35 files reviewed, 1 unresolved discussion (waiting on @BohuTANG, @dantengsky, and @zhyass)


src/meta/api/src/schema_api_impl.rs line 3485 at r3 (raw file):

        let mut reply = vec![];
        for prefix in &req.prefixes {
            let list = self.prefix_list_kv(prefix).await?;

Use list_kv() instead of prefix_list_kv() if possible.

list_kv() returns a Stream and won't be affected by the max gPRC message size.

@zhyass zhyass requested a review from drmingdrmer December 13, 2023 14:45
Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 3 files at r4, all commit messages.
Reviewable status: 6 of 37 files reviewed, 1 unresolved discussion (waiting on @BohuTANG, @dantengsky, and @zhyass)

@BohuTANG BohuTANG merged commit b86311a into databendlabs:main Dec 13, 2023
@BohuTANG
Copy link
Member

cc @soyeric128 for documenting this new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants