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

Valery Kharseko
15 hours ago c3e63df192c7ea16efeeda75a0603de2b617cf65
refs
author Valery Kharseko <vharseko@3a-systems.ru>
Sunday, November 1, 2026 18:54 +0100
committer GitHub <noreply@github.com>
Sunday, November 1, 2026 18:54 +0100
commitc3e63df192c7ea16efeeda75a0603de2b617cf65
tree c73159554b2a55e122fe5780165f867647b16a59 tree | zip | gz
parent 5c16b12648c1d14b92b75d2e7e42d0953843284c view | diff
[#1256] Remove incomplete changelog records completely during crash recovery (#1257)

Fixes #1256

After a replication server is killed during a changelog write, recovery
could truncate at the last block boundary while retaining the beginning
of an incomplete record. Subsequent appends then corrupted record
framing. In the failing `rs534, restart-rs` run of #1244, the server
reported successful recovery but later failed to decode the changelog
and repeatedly closed a directory server's connection.

`BlockLogReader.checkLogIsValid()` now uses the record start reached
through the block offset as the initial safe truncation position. For a
zero offset, it retains the block boundary so that the offset field is
removed with the incomplete record. If the crash interrupted the offset
itself, recovery starts from the preceding complete block. Errors
decoding a complete record remain fatal.

## Regression coverage

Thirteen `LogFileTest` cases exercise recovery through the normal
`LogFile` open path. They cover incomplete bodies across one or several
blocks, length headers split across blocks, zero offsets, exact block
boundaries, partially written offsets, and an incomplete first record.
Each checks the recovered length and newest record, appends a new
record, then reopens the file and reads the complete expected sequence.

On the original implementation, ten cases fail: six on the wrong
truncation position and four on EOF while reading an incomplete offset.
The other three cases and all 52 existing `LogFileTest` cases pass. With
the fix, all 65 pass.

## Validation

JDK 21, offline Maven reactor:

```sh
mvn -o -Pprecommit verify -pl opendj-server-legacy -am \
'-Dit.test=**/replication/server/changelog/file/*Test,MessageHandlerCatchUpTest,MissedUpdateRecoveryTest' \
-Dfailsafe.failIfNoSpecifiedTests=false \
-Dtest=NoTestsSelected -Dsurefire.failIfNoSpecifiedTests=false
```

- Reactor verify succeeds, including Javadoc: **1,457 integration tests
across 13 classes**, zero failures, errors or skips. The command selects
the file-changelog and handler-recovery tests and skips unrelated
Surefire tests.
- Before the change, the baseline reactor verify passed all 1,346
selected integration tests in `BlockLogReaderWriterTest`, `LogFileTest`
and `LogTest`, with upstream Surefire tests enabled.
- The standalone reproduction from #1256 now returns the correct
truncation position, **104**, instead of **256**.
- `git diff --check` passes.

The Docker `rs534, restart-rs` scenario was not rerun locally. This
change addresses the file-recovery defect in #1256; it does not claim to
resolve every other symptom in the CI run discussed there.
2 files modified
86 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/BlockLogReader.java 12 ●●●●● diff | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/server/changelog/file/LogFileTest.java 74 ●●●●● diff | view | raw | blame | history