fxbing opened a new pull request, #23975:
URL: https://github.com/apache/kafka/pull/23975
A periodic recovery checkpoint can sample recovery points before log
truncation and write them after the truncation checkpoint. The existing file
lock serializes writes but leaves sampling outside the critical section. The
resulting stale checkpoint can cause startup recovery to skip an unflushed
segment.
Serialize recovery point sampling and checkpoint writing on the
per-directory `OffsetCheckpointFile` instance. Both truncation paths use the
same critical section. The checkpoint format is unchanged.
Add a parameterized regression test covering `truncateTo` and
`truncateFullyAndStartAt`. It coordinates checkpointing with truncation,
verifies the persisted recovery point, and then rolls the log, injects CRC
corruption into the unflushed earlier segment, and reopens it to verify
recovery truncates the damaged data.
Testing:
- Before the fix, both concurrency cases failed with `expected: <0> but was:
<10>`.
- After the fix, all 82 tests in `LogManagerTest` and `LogLoaderTest` passed.
- Storage Checkstyle and SpotBugs checks passed.
```bash
./gradlew :storage:test \
--tests 'org.apache.kafka.storage.internals.log.LogManagerTest' \
--tests 'org.apache.kafka.storage.internals.log.LogLoaderTest' \
-PmaxParallelForks=1 -PmaxTestRetries=0
```
I contribute this original work under the project's Apache License 2.0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]