Skip to content

[#744] Fix flaky ChangelogBackendTestCase: keep generated CSN batches monotonic#745

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix-744-flaky-changelog-test-csns
Jul 17, 2026
Merged

[#744] Fix flaky ChangelogBackendTestCase: keep generated CSN batches monotonic#745
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix-744-flaky-changelog-test-csns

Conversation

@vharseko

Copy link
Copy Markdown
Member

Fixes #744.

Problem

ChangelogBackendTestCase.searchInChangeNumberModeOnOneSuffixMultipleTimes intermittently fails on CI (example run): after publishing a second batch of 4 changes, lastchangenumber stays at 4 instead of reaching 8 until the 30 s repeatUntilSuccess timer expires.

Root cause

The test helper generateCSNs() built CSNs from TimeThread.getTime() — a cached clock refreshed only every 200 ms — and restarted seqnum at 1 on every call. When the first batch's publish → index → search cycle completed within a single tick, the second call produced CSNs identical to the first batch's. The file-based changelog correctly refused them in LogFile.append ("Filtering out … because it would break ordering"), so change numbers 5–8 were never created.

The production CSNGenerator guarantees strictly increasing CSNs per replica, so this collision can only be produced by the test helper, which forges CSNs and bypasses it. Product code behaves as designed; see the analysis in #744.

Fix

Keep generateCSNs() monotonic across calls: remember the time of the last generated CSN and start the next batch at max(TimeThread.getTime(), lastTime + 1), mirroring the CSNGenerator.newCSN() invariant. Test-only change.

Verification

mvn -pl opendj-server-legacy verify -P precommit -Dit.test=ChangelogBackendTestCase — Tests run: 30, Failures: 0, Errors: 0, Skipped: 0.

…enerated CSN batches monotonic

generateCSNs() built CSNs from TimeThread.getTime(), which only refreshes
every 200 ms, restarting seqnum at 1 on every call. Two batches generated
within one tick produced identical CSNs, so the changelog silently filtered
the second batch out ("would break ordering") and lastchangenumber never
advanced, failing searchInChangeNumberModeOnOneSuffixMultipleTimes.

Start each batch after the previous one, mirroring the monotonicity
guarantee of the production CSNGenerator.
@vharseko
vharseko requested a review from maximthomas July 16, 2026 18:02
@vharseko vharseko added tests Test suites: fixing, enabling, un-disabling replication concurrency Thread-safety / race-condition bugs labels Jul 16, 2026
@vharseko
vharseko merged commit 772caa6 into OpenIdentityPlatform:master Jul 17, 2026
17 checks passed
@vharseko
vharseko deleted the fix-744-flaky-changelog-test-csns branch July 17, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

concurrency Thread-safety / race-condition bugs replication tests Test suites: fixing, enabling, un-disabling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: ChangelogBackendTestCase.searchInChangeNumberModeOnOneSuffixMultipleTimes fails when both change batches get identical CSNs

2 participants