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

using the Nacos2.2.2 and kingbase8 database update config conflit whit DuplicateKeyException #10353

Closed
justimaging opened this issue Apr 20, 2023 · 7 comments · Fixed by #11405
Labels
kind/discussion Category issues related to discussion
Milestone

Comments

@justimaging
Copy link

I am using kingbase8 database and my datasource plugin for nacos 2.2.2,when i update the config ,i occur caused: PreparedStatementCallback;错误: 重复键违反唯一约束"uk_configinfo_datagrouptenant"

justimaging added a commit to justimaging/nacos that referenced this issue Apr 20, 2023
caused: PreparedStatementCallback;错误: 重复键违反唯一约束"uk_configinfo_datagrouptenant"Detail: 键值
@KomachiSion
Copy link
Collaborator

see #10044 and #10045

@KomachiSion KomachiSion added the kind/discussion Category issues related to discussion label Apr 20, 2023
@YunWZ
Copy link
Contributor

YunWZ commented Apr 22, 2023

The intent of these statements is: Try { INSERT NEW CONFIGURATION } catch (DKE - this means that the configuration exists, so the same configuration needs to be updated. And we only need to update the existing configuration!).

DuplicateKeyException thrown when an attempt to insert or update data results in violation of a primary key or unique constraint.

DataIntegrityViolationException thrown when an attempt to insert or update data results in violation of an integrity constraint.

There are many scenarios where data constraint exceptions will occur, such as: the field is not empty

BTW we can't update an unexist cofnig!

@YunWZ
Copy link
Contributor

YunWZ commented Apr 22, 2023

If there are two "same" configurations in your database, check your config table DDL, do these two records have the same key or unique key?

@yanjinzh6
Copy link

missing sql-error-codes.xml for kingbase8?

@KomachiSion
Copy link
Collaborator

@YunWZ I see the DataIntegrityViolationException and DuplicateKeyException commend, Spring recommend to handle DataIntegrityViolationException but not DuplicateKeyException , should we revert to handle DataIntegrityViolationException?

commend in DuplicateKeyException

/**
 * ....
 * 
 * <p>Consider handling the general {@link DataIntegrityViolationException}
 * instead, semantically including a wider range of constraint violations.
 *
 * @author Thomas Risberg
 */

and commend in DataIntegrityViolationException

 * <p>Serves as a superclass for more specific exceptions, e.g.
 * {@link DuplicateKeyException}. However, it is generally
 * recommended to handle {@code DataIntegrityViolationException}
 * itself instead of relying on specific exception subclasses.

@YunWZ
Copy link
Contributor

YunWZ commented Oct 11, 2023

@YunWZ I see the DataIntegrityViolationException and DuplicateKeyException commend, Spring recommend to handle DataIntegrityViolationException but not DuplicateKeyException , should we revert to handle DataIntegrityViolationException?

commend in DuplicateKeyException

/**
 * ....
 * 
 * <p>Consider handling the general {@link DataIntegrityViolationException}
 * instead, semantically including a wider range of constraint violations.
 *
 * @author Thomas Risberg
 */

and commend in DataIntegrityViolationException

 * <p>Serves as a superclass for more specific exceptions, e.g.
 * {@link DuplicateKeyException}. However, it is generally
 * recommended to handle {@code DataIntegrityViolationException}
 * itself instead of relying on specific exception subclasses.

Well, that's a good suggestion, we should handle all exception cases instead of just `DuplicateKeyException.

Of course, in this case we should to do two things:

  1. When catching DuplicateKeyException, we need to update record;
  2. Otherwise, tell the method's caller some information (for example, throw an exception).Because users may customize their owner database plugin.

What do you think?

@KomachiSion
Copy link
Collaborator

Currently, handling DataIntegrityViolationException and DuplicateKeyException together, but log more inforamtion for DataIntegrityViolationException. Future might use new way to handle it like #10672

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/discussion Category issues related to discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants