You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/09 10:20:30 UTC

[GitHub] [pulsar] dragonls opened a new issue, #17572: [Bug] Subscription is deleted unexpectedly

dragonls opened a new issue, #17572:
URL: https://github.com/apache/pulsar/issues/17572

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
   
   
   ### Version
   
   2.8.3
   
   ### Minimal reproduce step
   
   Set up a Pulsar cluster and set the broker to enable subscription expiry check (`subscriptionExpirationTimeMinutes>0`).
   
   1. Having a topic `persistent://test/test/test` with durable subscription `sub-test`, running on `broker A`. The consumer of subscription `sub-test` should run stably longer than `subscriptionExpirationTimeMinutes`.
   2. Make `broker A` stuck, such as `gdb attach <broke A pid>`, and then `kill -9 <consumer pid>; kill -9 <broke A pid>`. The main purpose is to prevent the broker from exiting normally and prevent the consumer from reconnecting to new broker ASAP.
   3. The topic `persistent://test/test/test` will be owned by another `broker X`, and recover the cursor of subscription `sub-test` with `lastActive` time, which mostly is the start time of previous consumer.
   4. The `broker X` will do subscription expiry check in `subscriptionExpiryCheckIntervalInMinutes` and then delete subscription `sub-test` of topic `persistent://test/test/test`.
   
   ### What did you expect to see?
   
   The new broker should not delete subscription `sub-test` of topic `persistent://test/test/test`, because it is still active just before `broker A` stopped.
   The new broker should recover the cursor of subscription `sub-test` with `lastActive` time correctly, which should be the real last active time of the consumer, such as just the time before consumer stopped.
   
   ### What did you see instead?
   
   Subscription `sub-test` of topic `persistent://test/test/test` is deleted unexpectedly.
   
   ### Anything else?
   
   This bug mostly happened while there are brokers shutdown with OOM or other situation, which make the broker not shutdown gracefully. And the new broker load the topics and then do subscription expiry check soon before consumer reconnected, then the subscription may be deleted unexpectedly.
   
   The broker use `sub.cursor.getLastActive()` to do subscription expiry check.
   https://github.com/apache/pulsar/blob/200f433002edf17da935eb7429e1b8a43a46eaba/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L2354-L2357
   
   The `lastActive` in `ManagedCursorImpl` only be updated in 3 places:
   - `org.apache.pulsar.broker.service.persistent.PersistentSubscription#addConsumer`
   - `org.apache.pulsar.broker.service.persistent.PersistentSubscription#removeConsumer`
   - `org.apache.bookkeeper.mledger.impl.ManagedCursorImpl#internalResetCursor`
   
   So it will be be updated during stable consumption.
   
   
   ### Are you willing to submit a PR?
   
   - [X] I'm willing to submit a PR!


-- 
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.apache.org

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


[GitHub] [pulsar] codelipenghui closed issue #17572: [Bug] Subscription is deleted unexpectedly

Posted by GitBox <gi...@apache.org>.
codelipenghui closed issue #17572: [Bug] Subscription is deleted unexpectedly
URL: https://github.com/apache/pulsar/issues/17572


-- 
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


[GitHub] [pulsar] dragonls commented on issue #17572: [Bug] Subscription is deleted unexpectedly

Posted by GitBox <gi...@apache.org>.
dragonls commented on issue #17572:
URL: https://github.com/apache/pulsar/issues/17572#issuecomment-1241791423

   Updating `lastActive` in `ManagedCursorImpl` during stable consumption can fix this bug.
   
   Fox example, add `cursor.updateLastActive()` to the end of `org.apache.pulsar.broker.service.persistent.PersistentSubscription#acknowledgeMessage` but I am not sure whether this is the right place.
   
   


-- 
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