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

Open
wants to merge 5 commits into
base: bz/share-pg-stream
Choose a base branch
from

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 the 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

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Signed-off-by: Bugen Zhao <[email protected]>
@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
Comment on lines 224 to 234
let mut process = std::pin::pin!(async {
let msg = match self.read_message().await {
Ok(msg) => msg,
Err(e) => {
tracing::error!(error = %e.as_report(), "error when reading message");
return false;
}
};
tracing::trace!(?msg, "received message");
self.process(msg).await
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Extracted from handle_connection

@BugenZhao BugenZhao marked this pull request as draft February 4, 2025 10:57
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
@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.

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.

2 participants