feat: enable graceful shutdown of persistent subscription consumer#5619
feat: enable graceful shutdown of persistent subscription consumer#5619avens19 wants to merge 1 commit into
Conversation
This pull request adds a new client message type to the persistent subscription channel. Sending stop from the client will remove the consumer from the strategy pool but will leave the grpc connection alive. This allows the consumer to finish processing in-flight events, ack/nack as needed and then unsubscribe. This avoids the likelihood of double-processing in-flight events as just calling unsusbscribe automatically retries in-flight events
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
|
Hi thanks for this! We'll take a look over the next few days |
|
/review |
PR Reviewer Guide 🔍Warning
Here are some key observations to aid the review process:
|
|
Heya, Just to clarify, we're looking to improve the graceful termination behaviour with respect to duplicate processing of in-flight/'still being worked on' events, do we mean
(or more than one of the above) Thanks! |
|
2 was my primary goal, though 3 is also unideal |
|
@timothycoleman do you need any more info? |
|
Hi @avens19, Sorry it's taking a while, it affects the API (albeit in a small way) and therefore the client SDKs and so we're discussing it internally. What client SDK are you using, and do you also have code changes on the client side? I'm mostly It may be that since we're not getting a 'Stopped' message in reponse, it'll behave the same as a client-side only mechanism that:
Without involving the server before the termination? |
|
I have not implemented any clients, we're using the NodeJS client. Ya my thinking was that it ultimately doesn't matter since the fallback is the existing behaviour. (IE: if there's a race and the server tries to send me an event while I send stop and have no items in the queue, I will exit immediately, ignore the event and the server will retry it on another client as it does today). I plan to continue working on any events I've received, adding any new events I receive during the drain to the queue and then calling the existing unsubscribe. All of this is best effort with the existing behaviour as the fallback. You're right that it's similar to a client-only solution which is why I mentioned that this also helps with your # 3 from above. Those events that I'm silently ignoring will end up being delayed and out of order relative to other events. I know there are no guarantees for this in general but ideally we'd do our best to prevent. |
|
I did implement the client-side solution on my side which you're right does solve # 2 from above which I said was my primary concern, so fair callout |
This pull request adds a new client message type to the persistent subscription channel. Sending stop from the client will remove the consumer from the strategy pool but will leave the grpc connection alive. This allows the consumer to finish processing in-flight events, ack/nack as needed and then unsubscribe. This avoids the likelihood of double-processing in-flight events as just calling unsubscribe automatically retries in-flight events
NOTE: this PR was created with the help of Claude (Opus 4.7)