Skip to content

Add identity cache refill regression tests - #37323

Open
kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:fix/identity-incrementer-zero-cache
Open

kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:fix/identity-incrementer-zero-cache

Conversation

@kalayciburak

@kalayciburak kalayciburak commented Sep 22, 2026 •

Copy link
Copy Markdown

Summary

This PR now adds tests only. The production fix for AbstractIdentityColumnMaxValueIncrementer was merged separately in #37402 and is already in this branch's base.

The tests exercise a failed insert during an identity cache refill:

The existing implementation publishes the replacement cache only after both allocation and the cleanup delete succeed. If cleanup fails, a later call refills the cache. This PR does not change that behavior.

Tests

On an isolated archive of PR head 94257105947449a9490818cf6f0a644a199cc528, with JDK 25 and offline dependencies:

./gradlew :spring-jdbc:test --rerun --tests org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementerTests --tests org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementerTests --no-daemon --console=plain --offline --no-build-cache

18 tests passed with no failures, errors, or skips. Compilation outputs were reused, and the archive did not contain Git metadata. This is a focused local run, not a CI result.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 22, 2026
@sbrannen sbrannen added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Sep 22, 2026
@kalayciburak
kalayciburak force-pushed the fix/identity-incrementer-zero-cache branch from a783ca9 to 03021c2 Compare October 13, 2026 23:02
@kalayciburak
kalayciburak force-pushed the fix/identity-incrementer-zero-cache branch 5 times, most recently from 14e63b4 to c05f8c8 Compare October 26, 2026 12:56
AbstractIdentityColumnMaxValueIncrementer published valueCache and
nextValueIndex before the insert/identity loop finished. A failed
insert left a zero-filled cache in place, so the next call returned 0
instead of retrying the database. The same path served a partial
cache when a later insert in the batch failed.

Build the cache locally and publish it only after every identity read
succeeds. A failed allocation leaves the previous index unchanged, so
the next call retries. Cleanup delete still runs after publish, so a
delete failure does not discard ids that were actually allocated.

Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
@kalayciburak
kalayciburak force-pushed the fix/identity-incrementer-zero-cache branch from c05f8c8 to 9425710 Compare October 26, 2026 13:26
@kalayciburak kalayciburak changed the title Avoid serving a zero cache after identity failure Add identity cache refill regression tests Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: data Issues in data modules (jdbc, orm, oxm, tx) status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants