Skip to content

Conversation

@gaozhangmin
Copy link
Contributor

To prioritize replication of newly created ledgers, we sort ledger IDs in descending order.
This ensures that recent ledgers (with larger IDs) are replicated first.
As a result, some older ledgers may expire before they are ever replicated, which helps to reduce unnecessary data replication and improve efficiency.

Collections.shuffle(children);
} else {
Collections.sort(children, Collections.reverseOrder());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't very readable; I recommend optimizing it.
What does the magic number 3 mean? I recommend including constants to explain their names.

@StevenLuMT
Copy link
Member

CI Error: /home/runner/work/bookkeeper/bookkeeper/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java:212:62: ',' is not followed by whitespace. [WhitespaceAfter]

@gaozhangmin
Copy link
Contributor Author

@gaozhangmin @StevenLuMT PTAL

@gaozhangmin
Copy link
Contributor Author

rerun failure checks

1 similar comment
@StevenLuMT
Copy link
Member

rerun failure checks

Copy link
Member

@StevenLuMT StevenLuMT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good jobs

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the ledger replication logic to prioritize newer ledgers by processing larger ledger IDs first. The change aims to improve efficiency by allowing older ledgers to expire before replication if necessary.

  • Implements descending order sorting for ledger IDs during replication to prioritize newer ledgers
  • Maintains shuffling behavior at depth 3 to avoid lock contention between workers
  • Adds comprehensive test coverage to verify the new sorting behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
ZkLedgerUnderreplicationManager.java Implements conditional sorting logic to process larger ledger IDs first while preserving shuffle behavior at depth 3
TestLedgerUnderreplicationManager.java Adds test case to verify that larger ledger IDs are processed before smaller ones

gaozhangmin and others added 2 commits August 8, 2025 10:54
…ion/TestLedgerUnderreplicationManager.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…edgerUnderreplicationManager.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@gaozhangmin
Copy link
Contributor Author

rerun failure checks

@gaozhangmin
Copy link
Contributor Author

rerun failure checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants