[#744] Fix flaky ChangelogBackendTestCase: keep generated CSN batches monotonic#745
Merged
vharseko merged 1 commit intoJul 17, 2026
Conversation
…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.
maximthomas
approved these changes
Jul 17, 2026
maximthomas
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #744.
Problem
ChangelogBackendTestCase.searchInChangeNumberModeOnOneSuffixMultipleTimesintermittently fails on CI (example run): after publishing a second batch of 4 changes,lastchangenumberstays at 4 instead of reaching 8 until the 30 srepeatUntilSuccesstimer expires.Root cause
The test helper
generateCSNs()built CSNs fromTimeThread.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 inLogFile.append("Filtering out … because it would break ordering"), so change numbers 5–8 were never created.The production
CSNGeneratorguarantees 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 atmax(TimeThread.getTime(), lastTime + 1), mirroring theCSNGenerator.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.