SPR-16886 Provide two mechanisms for SQL Server sequence incrementers. #2065
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.
This PR is to address a deadlocking issue with MS SQL Server and is related to https://jira.spring.io/browse/SPR-16886. Please see that issue for details.
I tried to ensure that this fix does not break downstream projects that leverage the incrementer on SQL Server.
This means that all versions of SQL Server are still going to use a sequence table with the difference being that the incrementer uses a reaper interval to delete records out of the sequence table.
I have also included an incrementer that can leverage native database sequences in 2012 and higher. It will be at the discretion of each downstream project as to when/if they want to leverage the new incrementer.
I am open to any feedback or changes you might want to make. I had toyed with requiring a platform transaction manager being injected into the incrementer (and creating a new transaction when the reaping interval was reached) as an alternative to using a thread, but I felt that was a more invasive change to downstream projects.
I have also updated my little test harness to use "copies" of the incrementers I have submitted in this pull request: https://github.com/tkvangorder/jdbc-sqlserver-incrementer