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

[#2227] improvement(jdbc-backend): Improve the judgment of exception information in JDBC backend #2862

Merged
merged 4 commits into from
Apr 14, 2024

Conversation

xloya
Copy link
Contributor

@xloya xloya commented Apr 10, 2024

What changes were proposed in this pull request?

Determine exceptions more accurately based on SQL Exception error codes.

Why are the changes needed?

Fix: #2227

How was this patch tested?

Add the unit tests.

@xloya
Copy link
Contributor Author

xloya commented Apr 10, 2024

@yuqi1129 @qqqttt123 Please help take a look of this, thanks.

@xloya xloya closed this Apr 10, 2024
@xloya xloya reopened this Apr 10, 2024
@xloya xloya closed this Apr 10, 2024
@xloya xloya reopened this Apr 10, 2024
@jerryshao jerryshao requested a review from yuqi1129 April 12, 2024 06:18
public GravitinoRuntimeException toGravitinoException(
SQLException se, Entity.EntityType type, String name) {
switch (se.getErrorCode()) {
case 1062:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is 1062 the value defined by MySQL internally which means a table or a database already exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It means found a duplicated entry for a primary key or a unique key, see: https://dev.mysql.com/doc/connector-j/en/connector-j-reference-error-sqlstates.html.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please attach the document links to the code here? @xloya

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you please attach the document links to the code here? @xloya

Have added the document link in annotations.


private SQLExceptionConverterFactory() {}

public static synchronized void initConverter(Config config) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When will this method be accessed concurrently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is currently no concurrent access, just ensure the singleton of the converter in the factory class.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

@yuqi1129
Copy link
Contributor

Generally LGTM.

@qqqttt123 qqqttt123 changed the title [#2227] improve(jdbc backend): Improve the judgment of exception information in JDBC backend [#2227] improvement(jdbc backend): Improve the judgment of exception information in JDBC backend Apr 14, 2024
@qqqttt123 qqqttt123 changed the title [#2227] improvement(jdbc backend): Improve the judgment of exception information in JDBC backend [#2227] improvement(jdbc-backend): Improve the judgment of exception information in JDBC backend Apr 14, 2024
Copy link
Contributor

@qqqttt123 qqqttt123 left a comment

Choose a reason for hiding this comment

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

LGTM.

@yuqi1129
Copy link
Contributor

Merge into main, thanks for your contributions @xloya

@yuqi1129 yuqi1129 merged commit 9128db0 into apache:main Apr 14, 2024
22 checks passed
@xloya xloya deleted the issue-2227 branch June 20, 2024 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] Improve the judgment granularity of exception information in JDBC backend
3 participants