hangc0276 commented on code in PR #4844:
URL: https://github.com/apache/bookkeeper/pull/4844#discussion_r4758216139
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java:
##########
@@ -790,7 +790,7 @@ boolean isFlushRequired() {
@Override
public void checkpoint(Checkpoint checkpoint) throws IOException {
Checkpoint thisCheckpoint = checkpointSource.newCheckpoint();
- if (lastCheckpoint.compareTo(checkpoint) > 0) {
+ if (lastCheckpoint.isAfter(checkpoint)) {
Review Comment:
**Reproduced: the memtable still uses the lexicographic order, so it skips
the same flush this PR fixes here.**
`BookieImpl` passes the same `CheckpointSourceList` to every ledger storage,
including `SortedLedgerStorage`. `EntryMemTable.flushSnapshot` /
`snapshot(Checkpoint)` (lines ~185-247) and `EntryMemTableWithParallelFlusher`
(lines ~62-69) still gate on `kvmap.compareTo(requested) < 0`.
Scenario: a memtable's skip list is created at `[J1=2, J2=1]`, an entry is
added, and `SyncThread` asks for a concurrently sampled `[J1=1, J2=2]`. The
total order says `[2,1] > [1,2]`, so nothing is flushed. `checkpointComplete`
still lets the journal-2 position advance, so the entry exists only in the
memtable, which is the loss described in the PR.
Proof (uncommitted test in `EntryMemTableTest`, both memtable classes):
- `testAdvCompositeCheckpointIncomparableRequestStillFlushesMemTable` fails
with `memtable entry skipped for an incomparable composite checkpoint
expected:<1> but was:<0>`.
- The control `testAdvCompositeCheckpointControlComparableFlushes` (a
request later in both journals) passes.
I drove `EntryMemTable.flush(flusher, checkpoint)` directly and did not run
`SortedLedgerStorage` end to end with two journals.
Suggested fix: in those gates replace `cp.compareTo(req) < 0` with "flush
unless the memtable's checkpoint covers the request", i.e. `!cp.isAfter(req) &&
cp.compareTo(req) != 0`. For scalars this equals `cp < req`.
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/CheckpointSourceList.java:
##########
@@ -110,6 +110,35 @@ public int compareTo(Checkpoint o) {
return 0;
}
+ @Override
+ public boolean isAfter(Checkpoint o) {
+ if (o == Checkpoint.MAX) {
+ return false;
+ } else if (o == Checkpoint.MIN) {
+ return true;
+ }
+
+ checkArgument(o instanceof CheckpointList);
+ CheckpointList other = (CheckpointList) o;
+ if (checkpoints.size() != other.checkpoints.size()) {
Review Comment:
Nit (test gap): mutating this branch to `return true` still passes
`CheckpointSourceListTest` and the new DbLedgerStorage test, so the
size-mismatch path has no test. It looks unreachable in production because
`BookieImpl` builds one fixed-size list, so a one-line test or dropping the
branch would both be fine.
--
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]