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

Add a switch for investigating constraint violation and improve relative tip logs #664

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

ArgonarioD
Copy link
Contributor

Background

While Jimmer’s feature of investigating constraint violations greatly facilitates debugging and make functions like automatic retries in specific scenarios more easier to be implemented, it can impose unexpected and uncontrollable query loads on the database during large-scale data insertions. Therefore, I think this feature:

  • should be user-controllable
  • should be disabled by default

to minimize the risk of production incidents caused by unexpected query loads, and let users take the blame for them.

Additionally, Jimmer’s current behavior is inconsistent for databases that abort transactions upon errors (these databases do not investigate without an active transaction, while the others investigate constraint violations under any circumstances) and lacks notifications. Providing such notifications would enhance user-friendliness.

Modification

  1. Add a Boolean property investigateConstraintViolationEnabled to SqlClient. When set to true, the investigation feature is enabled; when set to false, it is disabled. If set to null, it indicates that the setting is not explicitly configured (default is disabled).
  2. Add the above property to the Spring Boot application properties.
  3. When this feature is not enabled, do not set a savepoint or conduct an investigation; directly execute convertFinalException.
  4. If the user has not explicitly set investigateConstraintViolationEnabled and a constraint violation exception occurs, issue a warning log prompting the user to explicitly set this value.
  5. If the user enables this feature and is using a database that aborts transactions upon errors, and the transaction is not activated, issue a warning log prompting the user to activate a transaction.

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.

1 participant