Skip to content

[fix][ml] Fix ledger left in OPEN state when enable inactiveLedgerRollOverTimeMs - #20276

Merged
poorbarcode merged 4 commits into
apache:masterfrom
lifepuzzlefun:fix_ledger_leak
May 16, 2023
Merged

poorbarcode merged 4 commits into
apache:masterfrom
lifepuzzlefun:fix_ledger_leak

Conversation

@lifepuzzlefun

@lifepuzzlefun lifepuzzlefun commented May 9, 2023 •

Copy link
Copy Markdown
Contributor

Motivation

when ledger close or rollover. ml will change to ClosingLedger state and close current ledger.
and call ledgerClosed method.

the inactiveLedgerRollOverTimeMs task didn't follow this routinue.

Modifications

patch the close logic when enable inactiveLedgerRollOverTimeMs this option

Verifying this change

add unit test to check all ledger is closed.

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

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: (lifepuzzlefun#18)

inactiveLedgerRollOverTimeMs
@github-actions

github-actions Bot commented May 9, 2023

Copy link
Copy Markdown

@lifepuzzlefun Please add the following content to your PR description and select a checkbox:

- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->

@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels May 9, 2023
@lhotari

lhotari commented May 10, 2023

Copy link
Copy Markdown
Member

@lifepuzzlefun Please run the tests at least once in your own fork and update the information of the PR in your own fork to the description of the PR. We do this to save the limited resources in our CI in apache/pulsar.

@lhotari
lhotari requested review from dlg99, eolivelli and hangc0276 May 10, 2023 09:53
@lifepuzzlefun

Copy link
Copy Markdown
Contributor Author

lifepuzzlefun#18 all test pass in my local repo. some of them fail on update cov file.

@lhotari

lhotari commented May 11, 2023

Copy link
Copy Markdown
Member

lifepuzzlefun#18 all test pass in my local repo. some of them fail on update cov file.

+1, please update this link to the PR description so that it can be found there.

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, good work @lifepuzzlefun

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, good work @lifepuzzlefun

@lhotari lhotari added type/bug The PR fixed a bug or issue reported a bug release/2.10.5 release/2.11.2 release/3.0.1 labels May 11, 2023
@lhotari lhotari added this to the 3.1.0 milestone May 11, 2023

ledgerClosed(lh);
// we do not create ledger here, since topic is inactive for a long time.
}, System.nanoTime());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The context System.nanoTime() is not used. Can we set this param to null?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agree. change both (inactive and rollover) callback ctx to null.

if (rc == Code.OK) {
log.debug("Successfully closed ledger {}", lh.getId());
} else {
log.warn("Error when closing ledger {}. Status={}", lh.getId(), BKException.getMessage(rc));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The log should include the name of this managed ledger object, such as

log.warn("[{}] Error when closing ledger...", name,...);

BTW, can you also change rollCurrentLedgerIfFull's log in this PR? And it is better to make these two logs are not the same, so it is easier to troubleshoot problems based on logs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah~ fix have been submitted, it looks with more detail now. nice suggestion!

@codecov-commenter

codecov-commenter commented May 15, 2023 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 27.77778% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.93%. Comparing base (00f17e8) to head (1e2f55c).
⚠️ Report is 2039 commits behind head on master.

Files with missing lines Patch % Lines
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 27.77% 8 Missing and 5 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #20276       +/-   ##
=============================================
+ Coverage     37.61%   72.93%   +35.32%     
- Complexity    12589    31948    +19359     
=============================================
  Files          1691     1868      +177     
  Lines        129028   138617     +9589     
  Branches      14066    15244     +1178     
=============================================
+ Hits          48530   101104    +52574     
+ Misses        74183    29461    -44722     
- Partials       6315     8052     +1737     
Flag Coverage Δ
inttests 24.15% <0.00%> (-0.02%) ⬇️
systests 24.94% <0.00%> (+0.16%) ⬆️
unittests 72.20% <27.77%> (+39.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 81.72% <27.77%> (+29.44%) ⬆️

... and 1429 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@poorbarcode
poorbarcode merged commit 426ad3e into apache:master May 16, 2023
Technoboy- pushed a commit that referenced this pull request May 16, 2023
…llOverTimeMs` (#20276)

close `currentLegder` after roll current ledger if full
Technoboy- pushed a commit that referenced this pull request May 23, 2023
…llOverTimeMs` (#20276)

close `currentLegder` after roll current ledger if full
poorbarcode pushed a commit that referenced this pull request May 30, 2023
…llOverTimeMs` (#20276)

close `currentLegder` after roll current ledger if full

(cherry picked from commit 426ad3e)
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jun 6, 2023
…llOverTimeMs` (apache#20276)

close `currentLegder` after roll current ledger if full

(cherry picked from commit 64688d5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants