Add a switch for investigating constraint violation and improve relative tip logs #664
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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
Boolean
propertyinvestigateConstraintViolationEnabled
toSqlClient
. When set totrue
, the investigation feature is enabled; when set tofalse
, it is disabled. If set tonull
, it indicates that the setting is not explicitly configured (default is disabled).convertFinalException
.investigateConstraintViolationEnabled
and a constraint violation exception occurs, issue a warning log prompting the user to explicitly set this value.