Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix retention size policy delete too much ledgers #11242

Merged
merged 3 commits into from
Jul 8, 2021

Conversation

aloyszhang
Copy link
Contributor

Fixes #11241

Motivation

This pull request fix the error that retention size policy delete too much ledgers when all cursors has no backlog

Modifications

  1. generate ledgersToDelete by checking ledger size one by one instead of TOTAL_SIZE_UPDATER
  2. refactor the logic of generate ledgersToDelete
  3. add test code

Verifying this change

This change added tests and can be verified as follows:

  • add test in ManagedLedgerTest.testRetentionSize()

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@merlimat merlimat added the type/bug The PR fixed a bug or issue reported a bug label Jul 7, 2021
@merlimat merlimat added this to the 2.9.0 milestone Jul 7, 2021
}
}

if (hasLedgerRetentionExpired(ls.getTimestamp())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why the PR can fix the problem. Looks the problem is the existing logic is if the ledger over retention quota or expired, the ledger will be added into the ledgersToDelete, the correct logic is if the ledger over retention quota and expired, we should add it into the ledgersToDelete right?

But looks like the new change still adds the ledger to the ledgersToDelete after over retention quota without checking the expired.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the correct logic is if the ledger over retention quota and expired, we should add it into the ledgersToDelete right?

I think the logic of retention policy means either over retention quota or expired, the ledger should be delete.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh. sorry, My mistake.

ManagedLedgerFactory factory = new ManagedLedgerFactoryImpl(metadataStore, bkc);
ManagedLedgerConfig config = new ManagedLedgerConfig();
config.setRetentionSizeInMB(retentionSizeInMB);
config.setMaxEntriesPerLedger(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a minRolloverTime limitation by default 10min, Set max 1 entry per ledger will not trigger the ledger rollover.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aloyszhang
Copy link
Contributor Author

/pulsarbot run-failure-checks

}
}

if (hasLedgerRetentionExpired(ls.getTimestamp())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh. sorry, My mistake.

@codelipenghui
Copy link
Contributor

Nice catch @aloyszhang

@codelipenghui codelipenghui merged commit 8ca6f19 into apache:master Jul 8, 2021
eolivelli pushed a commit to datastax/pulsar that referenced this pull request Jul 13, 2021
Fixes apache#11241
This pull request fix the error that retention size policy delete too much ledgers when all cursors has no backlog

1.  generate `ledgersToDelete` by checking ledger size one by one instead of `TOTAL_SIZE_UPDATER`
2. refactor the logic of generate `ledgersToDelete`
3. add test code

(cherry picked from commit 8ca6f19)
codelipenghui pushed a commit that referenced this pull request Jul 14, 2021
Fixes #11241
### Motivation
This pull request fix the error that retention size policy delete too much ledgers when all cursors has no backlog

### Modifications

1.  generate `ledgersToDelete` by checking ledger size one by one instead of `TOTAL_SIZE_UPDATER`
2. refactor the logic of generate `ledgersToDelete`
3. add test code

(cherry picked from commit 8ca6f19)
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Jul 14, 2021
@aloyszhang aloyszhang deleted the retention branch August 2, 2021 02:29
@aloyszhang aloyszhang restored the retention branch August 2, 2021 02:29
@aloyszhang aloyszhang deleted the retention branch August 2, 2021 02:29
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Dec 3, 2021
Fixes apache#11241
### Motivation
This pull request fix the error that retention size policy delete too much ledgers when all cursors has no backlog

### Modifications

1.  generate `ledgersToDelete` by checking ledger size one by one instead of `TOTAL_SIZE_UPDATER`
2. refactor the logic of generate `ledgersToDelete`
3. add test code

(cherry picked from commit 8ca6f19)
(cherry picked from commit 3ad707b)
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
Fixes apache#11241
### Motivation
This pull request fix the error that retention size policy delete too much ledgers when all cursors has no backlog

### Modifications

1.  generate `ledgersToDelete` by checking ledger size one by one instead of `TOTAL_SIZE_UPDATER`
2. refactor the logic of generate `ledgersToDelete`
3. add test code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.8 Archived: 2.8 is end of life release/2.8.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retention size policy may delete too much ledgers
3 participants