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

DuplicateKeyException check in JdbcTemplateStorageAccessor is Insufficient #1

Closed
techRJ opened this issue Jan 13, 2017 · 3 comments
Closed

Comments

@techRJ
Copy link

techRJ commented Jan 13, 2017

The insertRecord method in JdbcTemplateStorageAccessor catches only the DuplicateKeyException to ascertain whether the lock already exists. With Vertica DB this poses a problem as it throws a org.springframework.dao.DataIntegrityViolationException instead.
Note that this is the parent class of DuplicateKeyException. As such the catch block is skipped entirely and the exception is propagated to spring framework rendering ShedLock unusable.
I would like to propose that the DataIntegrityViolationException be caught instead so that this can work with Vertica.
IMHO maybe the base Exception class can be caught? Not sure if you have any other constraints around this so would leave that to you.
If you like, I can submit a pull request for this as well.

Exception encountered as below:
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [INSERT INTO SHEDLOCK(name, lock_until, locked_at, locked_by) VALUES(?, ?, ?, ?)]; [Vertica]VJDBC ERROR: Duplicate key values: 'name=batchStatusEmailTask' -- violates constraint 'SHEDLOCK.C_PRIMARY'; nested exception is java.sql.SQLIntegrityConstraintViolationException: [Vertica]VJDBC ERROR: Duplicate key values: 'name=batchStatusEmailTask' -- violates constraint 'SHEDLOCK.C_PRIMARY'

@lukas-krecan
Copy link
Owner

Thanks for feedback, will fix it ASAP.

@lukas-krecan
Copy link
Owner

Released as 0.4.1, will take few minutes to propagate to central repo

@techRJ
Copy link
Author

techRJ commented Jan 13, 2017

Thanks for the incredibly swift response! Great work!

lukas-krecan pushed a commit that referenced this issue May 9, 2017
Using embedded Redis for tests
lukas-krecan pushed a commit that referenced this issue May 29, 2020
Fix syntax used in annotation attribute value
lukas-krecan pushed a commit that referenced this issue Apr 10, 2021
Implemented granular control on CAS consistency.
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

No branches or pull requests

2 participants