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(pgwire): send notice asynchronously and promptly #20374

Merged
merged 8 commits into from
Feb 12, 2025

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Feb 4, 2025

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

What's changed and what's your intention?

This PR refactors the Session trait and PgProtocol to enable sending notices asynchronously and promptly to users before a command completes.

This is achieved by selecting a new task for forwarding notice and the task for processing the command.

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • My PR contains critical fixes that are necessary to be merged into the latest release.

Documentation

  • My PR needs documentation updates.
Release note

Copy link
Member Author

BugenZhao commented Feb 4, 2025

@BugenZhao BugenZhao changed the title feat(pgwire): send notice asynchronously feat(pgwire): send notice asynchronously and promptly Feb 4, 2025
@BugenZhao BugenZhao marked this pull request as ready for review February 4, 2025 06:59
@BugenZhao BugenZhao marked this pull request as draft February 4, 2025 10:57
@BugenZhao BugenZhao marked this pull request as ready for review February 5, 2025 09:03
Comment on lines 240 to 245
let next_notice = async {
let notice = session.next_notice().await;
notice_stream.write(&BeMessage::NoticeResponse(&notice)).await.inspect_err(|e| {
tracing::error!(error = %e.as_report(), notice, "failed to send notice");
}).ok();
};
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not cancellation-safe.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain more? I guess here no leaking will happen. And if the task is cancelled, it is ok to not send full notice to the user?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to not create a next_notice future every time when processing a message.

@BugenZhao BugenZhao requested a review from a team as a code owner February 11, 2025 07:30
Base automatically changed from bz/share-pg-stream to main February 11, 2025 10:31
Copy link
Member

@stdrc stdrc left a comment

Choose a reason for hiding this comment

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

L🐮TM

@BugenZhao BugenZhao enabled auto-merge February 12, 2025 06:47
@BugenZhao BugenZhao added this pull request to the merge queue Feb 12, 2025
Merged via the queue into main with commit 5de6edc Feb 12, 2025
29 checks passed
@BugenZhao BugenZhao deleted the bz/async-pg-notice branch February 12, 2025 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants