Fix race condition in ChangelogBackendTestCase.searchInChangeNumberModeOnOneSuffixMultipleTimes#604
Open
Fix race condition in ChangelogBackendTestCase.searchInChangeNumberModeOnOneSuffixMultipleTimes#604
Conversation
…ersed password not checked in substrings Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/012529c1-279e-4947-8f12-65a470e1a382 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/d6637020-91e6-4b63-af37-189a7f99f6fb Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/f8f7e4f3-d40a-445a-9d64-2470d1ce0430 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
… in containsSubstring Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/03d57c68-16a0-43e7-8a5f-045a080213af Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot
AI
changed the title
Fix race condition in ChangelogBackendTestCase
Fix race condition in ChangelogBackendTestCase.searchInChangeNumberModeOnOneSuffixMultipleTimes
Mar 30, 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.
Change number assignment is asynchronous server-side, so searching immediately after publishing replication messages could race ahead of the mapper — causing intermittent assertion failures when the expected 4 entries weren't yet visible within the 10-second retry window.
Changes
ChangelogBackendTestCase.java— added twoassertChangelogAttributesInRootDSEsynchronization barriers insearchInChangeNumberModeOnOneSuffixMultipleTimes:assertChangelogAttributesInRootDSE(1, 4)before searching the first batch (CNs 1–4)assertChangelogAttributesInRootDSE(1, 8)before searching the second batch (CNs 5–8)assertChangelogAttributesInRootDSEalready pollslastchangenumberin the root DSE via aTestTimerretry loop, making it the correct barrier rather than widening the search timeout.Original prompt
Problem
The CI job for PR #599 is failing with:
Root Cause
The test
searchInChangeNumberModeOnOneSuffixMultipleTimesinopendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.javahas a race condition. It publishes two batches of 4 replication messages and immediately searches
for them, but there is no synchronization barrier between publishing the messages and searching.
The change number assignment is done server-side asynchronously, so by the time the 10-second
searchChangelogretry loop runs, the second batch of change numbers (5–8) may not yet bevisible, causing the assertion
softly.assertThat(searchOp.getSearchEntries()).hasSize(4)to fail.Fix (Option 2 — proper synchronization)
Add
assertChangelogAttributesInRootDSEcalls before each search to wait for the changenumber mapper to finish assigning numbers. The
assertChangelogAttributesInRootDSEmethod alreadyuses a
TestTimerretry loop and checkslastchangenumberin the root DSE, making it the correctsynchronization point.
File to modify
opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.javaModify the
searchInChangeNumberModeOnOneSuffixMultipleTimesmethod (lines 580–611) as follows:Before:
After:
Summary of changes
searchChangesForEachOperationTypeUsingChangeNumberMode(1, ...), addassertChangelogAttributesInRootDSE(1, 4)to wait for change numbers 1–4 to be assigned.searchChangesForEachOperationTypeUsingChangeNumberMode(5, ...), addassertChangelogAttributesInRootDSE(1, 8)to wait for change numbers 5–8 to be...This pull request was created from Copilot chat.