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

refactor(pgwire): refactor error handle #3841

Merged
merged 9 commits into from
Jul 15, 2022
Merged

Conversation

ZENOTME
Copy link
Contributor

@ZENOTME ZENOTME commented Jul 13, 2022

I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.

What's changed and what's your intention?

refactor error handle in pgwire

Please explain IN DETAIL what the changes are in this PR and why they are needed:

  • Summarize your change (mandatory)
  • How does this PR work? Need a brief introduction for the changed logic (optional)
  • Describe clearly one logical change and avoid lazy messages (optional)
  • Describe any limitations of the current code (optional)

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

If your pull request contains user-facing changes, please specify the types of the changes, and create a release note. Otherwise, please feel free to remove this section.

Types of user-facing changes

Please keep the types that apply to your changes, and remove those that do not apply.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

#3829
Please create a release note for your changes. In the release note, focus on the impact on users, and mention the environment or conditions where the impact may occur.

Refer to a related PR or issue link (optional)

@ZENOTME ZENOTME force-pushed the zj/pgwire_error_handle_refactor branch 2 times, most recently from 93b4a97 to efec891 Compare July 13, 2022 10:55
@ZENOTME ZENOTME force-pushed the zj/pgwire_error_handle_refactor branch from efec891 to 2f013a2 Compare July 13, 2022 11:09
@codecov
Copy link

codecov bot commented Jul 13, 2022

Codecov Report

Merging #3841 (178f9fe) into main (81861d2) will increase coverage by 0.00%.
The diff coverage is 67.79%.

@@           Coverage Diff           @@
##             main    #3841   +/-   ##
=======================================
  Coverage   74.00%   74.00%           
=======================================
  Files         818      818           
  Lines      115304   115392   +88     
=======================================
+ Hits        85331    85400   +69     
- Misses      29973    29992   +19     
Flag Coverage Δ
rust 74.00% <67.79%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/utils/pgwire/src/error.rs 0.00% <0.00%> (ø)
src/utils/pgwire/src/pg_server.rs 91.58% <50.00%> (+2.11%) ⬆️
src/utils/pgwire/src/pg_protocol.rs 73.45% <68.11%> (+0.85%) ⬆️
...c/frontend/src/optimizer/plan_node/logical_scan.rs 89.33% <0.00%> (-1.16%) ⬇️
src/meta/src/manager/id.rs 95.50% <0.00%> (-0.57%) ⬇️
src/common/src/types/ordered_float.rs 29.10% <0.00%> (+0.19%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@ZENOTME ZENOTME requested a review from BowenXiao1999 July 13, 2022 11:20
@BugenZhao BugenZhao changed the title refactor(pgwire):refactor error handle refactor(pgwire): refactor error handle Jul 13, 2022
Copy link
Contributor

@BowenXiao1999 BowenXiao1999 left a comment

Choose a reason for hiding this comment

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

Rest LGTM

Comment on lines +300 to +305
self.write_message_no_flush(&BeMessage::AuthenticationOk)
.map_err(PsqlError::PasswordError)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

For write_message or write_message_no_flush, maybe we should not .map_err distinguish different type of error and all treat them like PsqlError::IoError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

write_message_no_flush in process_password and process_startup stiil need to map as PasswordError and StartupError. Because in process_password/process_startup, if write_message_no_flush return a error, you need to close a connection rather than just report it. So we can't treat it as a PsqlError::IoError, PsqlError::IoError will just report but not close connection.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I think every Io::Error should close connection. Let me take a look

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In past version, I think most of Io::Error don't close connection.

@ZENOTME ZENOTME force-pushed the zj/pgwire_error_handle_refactor branch 2 times, most recently from e5885ce to 6ea7d43 Compare July 15, 2022 03:37
@@ -131,7 +128,11 @@ where
Err(e) => {
tracing::error!("Error: {}", e);
match e {
PsqlError::CancelError(_) | PsqlError::SslError(_) | PsqlError::IoError(_) => {}
PsqlError::SslError(io_err) | PsqlError::IoError(io_err) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How to use '@' here..

}

async fn do_process(
async fn do_process_error(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest change the name here..

do_process and do_process_inner?

@ZENOTME ZENOTME force-pushed the zj/pgwire_error_handle_refactor branch from 6ea7d43 to 22df2cc Compare July 15, 2022 06:00
@mergify mergify bot merged commit 33c4383 into main Jul 15, 2022
@mergify mergify bot deleted the zj/pgwire_error_handle_refactor branch July 15, 2022 06:25
nasnoisaac pushed a commit to nasnoisaac/risingwave that referenced this pull request Aug 9, 2022
* add error type

* modify pg_server.rs

* modified error type

* modify error

* refactor do_process to more clear

* fix clippy

* refactor error handle

* modify error hanlde

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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