-
Notifications
You must be signed in to change notification settings - Fork 605
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
base: bz/share-pg-stream
Are you sure you want to change the base?
Conversation
Signed-off-by: Bugen Zhao <[email protected]>
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Signed-off-by: Bugen Zhao <[email protected]>
src/utils/pgwire/src/pg_protocol.rs
Outdated
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 | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted from handle_connection
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
let next_notice = async { | ||
let notice = session.next_notice().await; | ||
notice_stream.write(&BeMessage::NoticeResponse(¬ice)).await.inspect_err(|e| { | ||
tracing::error!(error = %e.as_report(), notice, "failed to send notice"); | ||
}).ok(); | ||
}; |
There was a problem hiding this comment.
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.
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 andPgProtocol
to enable sending notices asynchronously and promptly to users before a command completes.This is achieved by
select
ing the task for forwarding notice and the task for processing the command.Checklist
Documentation
Release note