Repository navigation
Description
Symptom
AliasTestCase.test_persistent_search_reports_repeated_changes fails intermittently on CI:
the test modifies the same entry three times and waits up to 30 s for each persistent search
notification; one of the notifications never arrives.
Two occurrences so far, both on the ubuntu-latest / 25 leg, both unrelated to the PR they
appeared in:
| Date | Run / job | Lost notification |
|---|---|---|
| 2026-07-30 | job 90885029058 (branch of #792) | change 2 |
| 2026-07-31 | job 91132255490 (PR #798) | change 3 |
[ERROR] AliasTestCase.test_persistent_search_reports_repeated_changes:591
[notification for change 3] expected:<"cn=changing,ou=psearch,o=test"> but was:<null>
[ERROR] Tests run: 31760, Failures: 1, Errors: 0, Skipped: 0
Which notification is lost varies, which is why this reads as a race rather than a
deterministic bug. Only the Linux legs of the matrix run this suite (-P precommit is set
for runner.os == 'Linux' only, .github/workflows/build.yml:92-95), so a green macOS or
Windows leg says nothing about this test.
The test was added in #742 (324d3c5dcb, 2026-07-16) together with the alias-dereferencing
fix for #739, so the flake can only have appeared since then.
What the server logs show
From the failure dump of the 2026-07-31 run — all three modifications were applied
successfully, within 8 ms of each other:
[31/Jul/2026:12:03:40 +0000] SEARCH REQ conn=2 op=1 msgID=2 base="ou=psearch,o=test" scope=sub filter="(objectClass=*)"
[31/Jul/2026:12:03:40 +0000] MODIFY REQ conn=1 op=18 msgID=19 dn="cn=changing,ou=psearch,o=test"
[31/Jul/2026:12:03:40 +0000] MODIFY RES conn=1 op=18 msgID=19 result=0 etime=1
[31/Jul/2026:12:03:40 +0000] MODIFY REQ conn=1 op=19 msgID=20 dn="cn=changing,ou=psearch,o=test"
[31/Jul/2026:12:03:40 +0000] MODIFY RES conn=1 op=19 msgID=20 result=0 etime=0
[31/Jul/2026:12:03:40 +0000] MODIFY REQ conn=1 op=20 msgID=21 dn="cn=changing,ou=psearch,o=test"
[31/Jul/2026:12:03:40 +0000] MODIFY RES conn=1 op=20 msgID=21 result=0 etime=0
[31/Jul/2026:12:04:10 +0000] DISCONNECT conn=2 reason="Client Disconnect"
There is no SEARCH RES conn=2 op=1 and no ABANDON: the persistent search was still alive
and was never cancelled — it simply never delivered the third notification, and the client
disconnected exactly 30 s later, when the test's poll(30, SECONDS) gave up. So one
notification is dropped silently, somewhere between PersistentSearch.processModify() and
the client.
A race that explains the 2026-07-30 occurrence
SearchOperationBasis keeps a set of the DNs already returned, so that an entry reached both
directly and through an alias is only sent once
(SearchOperationBasis.java:454-470):
private final Set<DN> returnedDNs = ConcurrentHashMap.newKeySet();
private volatile boolean searchPhaseOver;
public final void endSearchPhase() {
searchPhaseOver = true;
returnedDNs.clear();
}and consults it in returnEntry()
(SearchOperationBasis.java:602-611):
if (DereferenceAliasesPolicy.ALWAYS.equals(getDerefPolicy())
|| DereferenceAliasesPolicy.IN_SEARCHING.equals(getDerefPolicy())) {
...
if (!searchPhaseOver && !returnedDNs.add(entry.getName())) {
return true; // silently dropped
}
}endSearchPhase() is what stops this de-duplication from applying to persistent search
notifications — a persistent search must report every change, including repeated changes to
the same entry. But it is called after the search has been registered with the backend
(LocalBackendSearchOperation.java:235-263):
251: backend.registerPersistentSearch(persistentSearch); // visible to modify operations from here on
252: persistentSearch.enable();
256: if (processSearchNow) { backend.search(this); } // skipped when changesOnly
263: endSearchPhase();From line 251 onwards a concurrent MODIFY can already deliver a notification through
LocalBackendModifyOperation's post-response callback (LocalBackendModifyOperation.java:308-318)
→ PersistentSearch.sendEntry() (PersistentSearch.java:387-391) → returnEntry(), while
searchPhaseOver is still false. The first such notification adds the DN to returnedDNs
and is delivered; a second notification for the same entry, still inside that window, finds
the DN in the set and is dropped without a trace. That is exactly the 2026-07-30 failure
(first notification delivered, second lost).
The test makes that window easy to hit because it starts modifying as soon as the search
appears in backend.getPersistentSearches() (AliasTestCase.java:578-583) — i.e. as soon as
line 251 has run, not line 263.
This is not only a test problem: a real client running a changesOnly persistent search with
derefAliases: always (or in-searching) can miss a change the same way. Persistent searches
using the default neverDerefAliases are unaffected — the block above is only entered for the
two dereferencing policies.
What this does not explain
The 2026-07-31 failure lost the third notification after the first two were delivered.
searchPhaseOver is volatile and only ever goes false → true, so if the second
notification passed the check, the third cannot be swallowed by it. Either there is a second
window, or a second mechanism is at play. Ruled out by the evidence:
- not a cancelled/aborted persistent search — no
SEARCH RES, noABANDON, no error in the
server error log; - not a scope/filter mismatch — the three modifications are identical apart from the value of
description; - not concurrent test methods — the class is
@Test(sequential = true)and the run reports
Test classes run interleaved: 0; - not a failed modification — all three returned
result=0.
So the first step should be to reproduce it in a loop and confirm where the entry is lost,
rather than to fix the window above and assume the flake is gone.
Suggested fix
Do not route persistent search notifications through the search-phase de-duplication at all,
instead of relying on endSearchPhase() having already run: give PersistentSearch.sendEntry()
a path that bypasses returnedDNs (a dedicated SearchOperation method, or a flag on
returnEntry()). Moving endSearchPhase() above registerPersistentSearch() would close the
window only for changesOnly searches — a persistent search that also returns the initial
content has the same hole for the whole duration of the search phase, because the
de-duplication must stay active while that phase runs.
Notes
- The failing job burned 1 h 45 min before reporting the failure, and
-P precommitsets
rerunFailingTestsCount = 3(opendj-server-legacy/pom.xml), which did not retry this
method — see Confirm whether rerunFailingTestsCount applies to TestNG @DataProvider driven methods #801. - Reproduction: the class can be selected with
-Dit.test=AliasTestCaseunder-P precommit;
a single run is not enough, the failure needs repetition.
Activity
[OpenIdentityPlatform#807] Report persistent search terminations to t…
[#807] Do not drop persistent search notifications through search-pha…