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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]