Skip to content
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

feat: improve observability for subscription/cursor SHOW commands #18896

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

hzxa21
Copy link
Collaborator

@hzxa21 hzxa21 commented Oct 14, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Limitations for subscription/cursor SHOW commands prior to this PR:

  • Output only contains the name of the subscription and cursor.
  • SHOW CURSORS / SHOW SUBSCRIPTION CURSORS only show cursor names in the current session where the show command is run.

After this PR:

  • SHOW CURSORS / SHOW SUBSCRIPTION CURSORS output all cursor information across active sessions in the same frontend node.
  • SHOW CURSORS outputs Id | User | Host | Database | Cursor Name
  • SHOW SUBSCRIPTION CURSORS outputs Id | User | Host | Database | Cursor Name | Subscription Name | State | Idle Duration Ms
  • SHOW SUBSCRIPTIONS outputs Name | Retention Seconds

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

Enhance SHOW command for subscription and subscription cursor:

  • SHOW CURSORS / SHOW SUBSCRIPTION CURSORS output all cursor information across active sessions in the same frontend node.
  • SHOW CURSORS outputs Id | User | Host | Database | Cursor Name
  • SHOW SUBSCRIPTION CURSORS outputs Id | User | Host | Database | Cursor Name | Subscription Name | State | Idle Duration Ms
  • SHOW SUBSCRIPTIONS outputs Name | Retention Seconds

@hzxa21 hzxa21 added the user-facing-changes Contains changes that are visible to users label Oct 14, 2024
@hzxa21 hzxa21 requested a review from xxhZs October 14, 2024 08:57
@hzxa21
Copy link
Collaborator Author

hzxa21 commented Oct 14, 2024

Examples:

dev=> create subscription test_subscription from test_table with (retention = '1d');
CREATE_SUBSCRIPTION
dev=> show subscriptions;
       Name        | Retention Seconds 
-------------------+-------------------
 test_subscription |             86400
(1 row)

-- session 1
dev=> declare session1_cursor subscription cursor for test_subscription;
DECLARE_CURSOR

-- session 2
dev=> declare session2_cursor subscription cursor for test_subscription;
DECLARE_CURSOR

-- session 3
dev=> show subscription cursors;
 Id | User |      Host       | Database |   Cursor Name   | Subscription Name |                                      State                                       | Idle Duration Ms 
----+------+-----------------+----------+-----------------+-------------------+----------------------------------------------------------------------------------+------------------
 1  | root | 127.0.0.1:47777 | dev      | session2_cursor | test_subscription | InitLogStoreQuery { seek_timestamp: 7317774995947520, expected_timestamp: None } |             5378
 0  | root | 127.0.0.1:47775 | dev      | session1_cursor | test_subscription | InitLogStoreQuery { seek_timestamp: 7317774079950848, expected_timestamp: None } |            19355
(2 rows)

Copy link
Contributor

@xxhZs xxhZs left a comment

Choose a reason for hiding this comment

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

lgtm

src/frontend/src/handler/show.rs Outdated Show resolved Hide resolved
@hzxa21 hzxa21 added this pull request to the merge queue Oct 14, 2024
Merged via the queue into main with commit f217edd Oct 14, 2024
29 of 30 checks passed
@hzxa21 hzxa21 deleted the patrick/fix-show-cursors branch October 14, 2024 13:38
hzxa21 added a commit that referenced this pull request Nov 5, 2024
hzxa21 added a commit that referenced this pull request Nov 5, 2024
hzxa21 pushed a commit that referenced this pull request Nov 8, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 8, 2024
… commands (#18896) (#19269)

Co-authored-by: Xinhao Xu <84456268+xxhZs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants