You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "rdhabalia (via GitHub)" <gi...@apache.org> on 2023/11/02 23:28:53 UTC

[PR] [fix][broker] Fix failure while creating non-durable cursor with inactive managed-ledger [pulsar]

rdhabalia opened a new pull request, #21508:
URL: https://github.com/apache/pulsar/pull/21508

   
   ### Motivation
   
   Right now, the broker is failing to create a reader for a topic that is inactive and has deleted the inactive ledger as it has reached the inactive-ledger-timeout threshold. inactive-ledger-deletion task deletes inactive ledger but it doesn't create a new ledger because of that such topic stays with `LedgerClosed` state and without active ledger, and meanwhile if any reader tries to connect on that topic then reader creation fails with below error
   
   ```
   09:55:28.217 [pulsar-io-4-26] WARN  org.apache.pulsar.broker.service.ServerCnx - [/67.195.180.205:57218][persistent://tenant1/us-east1/ns1/t1][rea
   der-8a3095b8c5] Failed to create consumer: consumerId=15, null
   java.util.concurrent.CompletionException: java.util.NoSuchElementException
           at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314) ~[?:?]
           at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1113) ~[?:?]
           at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235) ~[?:?]
           at org.apache.pulsar.broker.service.persistent.PersistentTopic.internalSubscribe(PersistentTopic.java:717) ~[pulsar-broker.jar]
           at org.apache.pulsar.broker.service.persistent.PersistentTopic.subscribe(PersistentTopic.java:693) ~[pulsar-broker.jar]
           at org.apache.pulsar.broker.service.ServerCnx.lambda$handleSubscribe$12(ServerCnx.java:1095) ~[pulsar-broker.jar]
   :
   java.util.NoSuchElementException
   	at java.base/java.util.concurrent.ConcurrentSkipListMap.firstKey(ConcurrentSkipListMap.java:1859)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.getFirstPosition(ManagedLedgerImpl.java:3715)
   	at org.apache.bookkeeper.mledger.impl.NonDurableCursorImpl.<init>(NonDurableCursorImpl.java:59)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1127)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1108)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1100)
   
   
   Stats-internal
   {
     "entriesAddedCounter" : 0,
     "numberOfEntries" : 0,
     "totalSize" : 0,
     "currentLedgerEntries" : 0,
     "currentLedgerSize" : 0,
     "lastLedgerCreatedTimestamp" : "2023-10-26T15:24:57.886Z",
     "waitingCursorsCount" : 26,
     "pendingAddEntriesCount" : 0,
     "lastConfirmedEntry" : "1000:-1",
     "state" : "ClosedLedger",
     "ledgers" : [ ],
   
   ```
   
   ### Modifications
   
   Make sure, inactive-ledger-timeout task creates a new ledger after deleting inactive ledger to avoid above such failures while creating reader and subscription cursor.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *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
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `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 -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: <!-- ENTER URL HERE -->
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Fix failure while creating non-durable cursor with inactive managed-ledger [pulsar]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21508:
URL: https://github.com/apache/pulsar/pull/21508#issuecomment-1791700689

   @rdhabalia 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 -->
   ```


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Fix failure while creating non-durable cursor with inactive managed-ledger [pulsar]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #21508:
URL: https://github.com/apache/pulsar/pull/21508#issuecomment-1791958663

   ## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/21508?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#21508](https://app.codecov.io/gh/apache/pulsar/pull/21508?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (1744b2d) into [master](https://app.codecov.io/gh/apache/pulsar/commit/78fc853fc5291ab65b78613d662785a210cafa91?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (78fc853) will **increase** coverage by `39.86%`.
   > Report is 1 commits behind head on master.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/pulsar/pull/21508/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/pulsar/pull/21508?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@              Coverage Diff              @@
   ##             master   #21508       +/-   ##
   =============================================
   + Coverage     33.39%   73.26%   +39.86%     
   - Complexity    12194    32625    +20431     
   =============================================
     Files          1638     1890      +252     
     Lines        127949   140442    +12493     
     Branches      13952    15436     +1484     
   =============================================
   + Hits          42733   102897    +60164     
   + Misses        79564    29459    -50105     
   - Partials       5652     8086     +2434     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pulsar/pull/21508/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [inttests](https://app.codecov.io/gh/apache/pulsar/pull/21508/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `24.11% <33.33%> (-0.05%)` | :arrow_down: |
   | [systests](https://app.codecov.io/gh/apache/pulsar/pull/21508/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `24.76% <33.33%> (?)` | |
   | [unittests](https://app.codecov.io/gh/apache/pulsar/pull/21508/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `72.56% <100.00%> (+40.74%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files](https://app.codecov.io/gh/apache/pulsar/pull/21508?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...a/org/apache/bookkeeper/mledger/ManagedLedger.java](https://app.codecov.io/gh/apache/pulsar/pull/21508?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-bWFuYWdlZC1sZWRnZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Jvb2trZWVwZXIvbWxlZGdlci9NYW5hZ2VkTGVkZ2VyLmphdmE=) | `0.00% <ø> (ø)` | |
   | [...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java](https://app.codecov.io/gh/apache/pulsar/pull/21508?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-bWFuYWdlZC1sZWRnZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Jvb2trZWVwZXIvbWxlZGdlci9pbXBsL01hbmFnZWRMZWRnZXJJbXBsLmphdmE=) | `80.90% <100.00%> (+41.65%)` | :arrow_up: |
   
   ... and [1539 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/21508/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Fix failure while creating non-durable cursor with inactive managed-ledger [pulsar]

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #21508:
URL: https://github.com/apache/pulsar/pull/21508#discussion_r1498563939


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -4476,10 +4476,13 @@ public void checkInactiveLedgerAndRollOver() {
                     }
 
                     ledgerClosed(lh);
+                    createLedgerAfterClosed();

Review Comment:
   @rdhabalia @vineeth1995 @lhotari 
   
   I removed this line (`createLedgerAfterClosed();`), but the test `testNonDurableCursorCreateForInactiveLedger ` still passes.
   
   I think the root cause of the issue you encountered is the `ManagedLedegrImpl.ledgers` is empty due to other bugs. So, I want to revert this PR.
   
   
   <img width="823" alt="Screenshot 2024-02-22 at 11 24 32" src="https://github.com/apache/pulsar/assets/25195800/fb9fb7a9-8ac0-4e6e-a054-ceffca897d26">
   
   



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Fix failure while creating non-durable cursor with inactive managed-ledger [pulsar]

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #21508:
URL: https://github.com/apache/pulsar/pull/21508#discussion_r1498563939


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -4476,10 +4476,13 @@ public void checkInactiveLedgerAndRollOver() {
                     }
 
                     ledgerClosed(lh);
+                    createLedgerAfterClosed();

Review Comment:
   @rdhabalia @vineeth1995 @lhotari 
   
   I removed this line (`createLedgerAfterClosed();`), but the test `testNonDurableCursorCreateForInactiveLedger ` still passes.
   
   I think the root cause of the issue you encountered is the `ManagedLedegrImpl.ledgers` is empty due to other bugs. So, I want to revert this PR.
   ```
   java.util.NoSuchElementException
   	at java.base/java.util.concurrent.ConcurrentSkipListMap.firstKey(ConcurrentSkipListMap.java:1859)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.getFirstPosition(ManagedLedgerImpl.java:3715)
   	at org.apache.bookkeeper.mledger.impl.NonDurableCursorImpl.<init>(NonDurableCursorImpl.java:59)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1127)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1108)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1100)
   ```
   



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Fix failure while creating non-durable cursor with inactive managed-ledger [pulsar]

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #21508:
URL: https://github.com/apache/pulsar/pull/21508#discussion_r1498563939


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -4476,10 +4476,13 @@ public void checkInactiveLedgerAndRollOver() {
                     }
 
                     ledgerClosed(lh);
+                    createLedgerAfterClosed();

Review Comment:
   @rdhabalia @vineeth1995 @lhotari 
   
   I removed this line (`createLedgerAfterClosed();`), but the test `testNonDurableCursorCreateForInactiveLedger ` still passes.
   
   I think the root cause of the issue you explained is the `ManagedLedegrImpl.ledgers` is empty due to other bugs. So, I want to revert this PR.
   ```
   java.util.NoSuchElementException
   	at java.base/java.util.concurrent.ConcurrentSkipListMap.firstKey(ConcurrentSkipListMap.java:1859)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.getFirstPosition(ManagedLedgerImpl.java:3715)
   	at org.apache.bookkeeper.mledger.impl.NonDurableCursorImpl.<init>(NonDurableCursorImpl.java:59)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1127)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1108)
   	at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1100)
   ```
   



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Fix failure while creating non-durable cursor with inactive managed-ledger [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on PR #21508:
URL: https://github.com/apache/pulsar/pull/21508#issuecomment-1963672556

   And it's a break change to the `ManagedLedger.java` since we already have `@InterfaceStability.Stable` 
   
   ```
     /**
      * Can evolve while retaining compatibility for minor release boundaries.;
      * can break compatibility only at major release (ie. at m.0).
      */
     @Documented
     public @interface Stable {}
   ````


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Fix failure while creating non-durable cursor with inactive managed-ledger [pulsar]

Posted by "rdhabalia (via GitHub)" <gi...@apache.org>.
rdhabalia merged PR #21508:
URL: https://github.com/apache/pulsar/pull/21508


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org