-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
duplicate key value violates unique constraint "int_lock_pk" #3866
Comments
May we see the whole stack trace, please? I think we can fix that
If that is really what is recommended for handling duplicate keys in PostgreSQL ... Another way would be to let this In
where a So, WDYT? What would be the best way to address this concern from the framework perspective? |
The error is logged only in postgres itself, there is no stacktrace in our application. I think the workaround is fine because the result is 0 rows are updated, by which acquire will retry (please correct me if I am wrong). It would be great if it works out of the box in the best possible way. Is it an idea to ask from different db vendors input on what the best queries are, and then have these as defaults? But that after years being in the field I am the first asking for such a thing already indicates that this is probably not needed (it already works out of the box fine). So think current workaround is good enough. When more people come with similar problems probably a better decision can be made what kind of change must be made. From my side you can close this ticket. Thanks for the input! |
I doubt that any vendor provide such an info. And I guess that's a reason why even Hibernate has that We have some Although I still be upset that its driver does not throw any exceptions to the client 😢 ... If you are OK with the fix for this issue as setters for those queries, then we won't close this as |
Setters is fine with me. |
Hi @artembilan can I contribute to this? |
Sure! You are welcome! |
Fixes spring-projects#3866 Some RDBMS vendors (or their JDBC drivers) may just log the problem without throwing an exception. * Expose setters for UPDATE and INSERTS queries in the `DefaultLockRepository` to let end-user to modify them respectively, e.g. be able to add a PostgreSQL `ON CONFLICT DO NOTHING` hint. * Refactor `DefaultLockRepository` to `Instant` instead of `LocalDateTime` with zone offset. * Refactor `ttl` property to `Duration` type * Fix `dead-lock` typo to `deadlock`
Fixes #3866 Some RDBMS vendors (or their JDBC drivers) may just log the problem without throwing an exception. * Expose setters for UPDATE and INSERTS queries in the `DefaultLockRepository` to let end-user to modify them respectively, e.g. be able to add a PostgreSQL `ON CONFLICT DO NOTHING` hint. * Refactor `DefaultLockRepository` to `Instant` instead of `LocalDateTime` with zone offset. * Refactor `ttl` property to `Duration` type * Fix `dead-lock` typo to `deadlock`
In what version(s) of Spring Integration are you seeing this issue?
For example:
5.5.14
Describe the bug
When using DefaultLockRepository The following error is shown in postgres log under high load:
STATEMENT: INSERT INTO INT_LOCK (REGION, LOCK_KEY, CLIENT_ID, CREATED_DATE) VALUES ($1, $2, $3, $4)
ERROR: duplicate key value violates unique constraint "int_lock_pk"
To Reproduce
Use DefaultLockRepository with high load with postgres
Expected behavior
No error
** Workaround **
We use below workaround, but would be nice if this can be solved somewhere in spring integration itself:
The text was updated successfully, but these errors were encountered: