mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
36 mins ago f82d22de94de20cb44775530e934eb8c26368484
refs
author Valery Kharseko <vharseko@3a-systems.ru>
Tuesday, December 1, 2026 18:06 +0100
committer GitHub <noreply@github.com>
Tuesday, December 1, 2026 18:06 +0100
commitf82d22de94de20cb44775530e934eb8c26368484
tree 246e507f250805f9cc35158efdf12ae77b3a44ec tree | zip | gz
parent 8672f11245231e8d7eecc2054653a3e3b133f1a3 view | diff
Stabilize replication failover and heartbeat timeout tests (#1353)

The Ubuntu / JDK 25 build on #1351 timed out in
`failoverTriesAnotherDiscoveryResponderWhenTheFormerRsRefusesConnection(1)`.
The directory server reconnected to the former replication server. The
test then waited 30 seconds for a retry on the alternate server. [Failed
CI
job](https://github.com/OpenIdentityPlatform/OpenDJ/actions/runs/46602539655/job/142487255450#step:16)

A controlled replay on Linux reproduced the timeout on master. The
former server accepted the discovery socket and handed it to a worker.
By the time the worker closed the listener, the accept thread had
entered another `accept()`. That call returned a second socket, and the
former server received `StartSessionMsg` on it.

The test now tells the accept thread to close the listener immediately
after it accepts the discovery socket. The worker can still reply on
that socket, and the broker's subsequent TCP connection to the former
server is refused. This exercises the fallback and retry introduced in
#1349.

The two queued-stop tests now use the same listener flag. One queues
`stop()` while the alternate server withholds its first session start
reply and checks that the broker skips the retry. The other queues
`stop()` while the broker waits for the alternate server's discovery
reply and checks that the alternate server receives only the discovery
probe.

Two follow-up changes address failures seen while verifying the rebased
PR.

- In `failoverAllowsOneRetryOfTheSurvivingRs(1, 1, OFFLINE)`, the client
saw a connection reset during TLS negotiation, before sending
`ServerStartMsg`. The surviving test server now allows 8 seconds for TLS
negotiation and restores the 2-second read timeout before the
replication handshake. If the test fails, its assertion includes the
first server-side handshake failure and the socket endpoints. The new
`createServerSessionOrThrow()` entry point preserves the original
`SSLException` for the caller.
- In the heartbeat test, a write finished 5.383 seconds after the server
went away. Two samples in `Session.send()` had been enough for the test
to tell the writer to stop. The test now keeps writing until the
original session closes, confirms that the directory server receives a
window credit before heartbeats stop, and checks the monitor's timeout
warning for that session. It then discards the old socket and verifies
delivery of the last change by CSN after reconnecting.

## Verification

- With the fix, the alternate server received one discovery probe, one
session attempt whose start reply timed out, and one successful retry.
- Temporarily removing the broker's retry made the corrected test fail
on premature isolation in the one-timeout case. The zero-timeout case
passed.
- The original failover fix passed all 49 cases in
`ReplicationBrokerStopTest` on Linux with Temurin 25.0.5.1, with zero
skips.
- A 3-second delay in TLS setup allowed the failover case to reach the
intended start-reply timeout and retry. A separate loopback test covers
both the existing TLS error return and propagation of the original
exception.
- A controlled write pause reproduced the early exit in the old
heartbeat test and passed with the fix. Disabling the monitor's socket
abort made the updated test fail on the blocked write.
- With a window credit delivered between two overdue heartbeat polls,
the previous test failed when the writer finished after 6.177 seconds.
The same schedule passed after removing the elapsed-time assertion.
- On the rebased PR branch, Maven `verify -Pprecommit` passed all 81
selected tests on macOS with JDK 17, including all 49 cases in
`ReplicationBrokerStopTest`, with zero skips.
3 files modified
167 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ReplSessionSecurity.java 29 ●●●●● diff | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ReplicationBrokerStopTest.java 101 ●●●●● diff | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/ReplSessionSecurityTest.java 37 ●●●●● diff | view | raw | blame | history