Skip to content

fix(pubsub): handle batch actor shutdown gracefully#4725

Merged
suzmue merged 1 commit intogoogleapis:mainfrom
suzmue:shutdown_actor
Feb 19, 2026
Merged

fix(pubsub): handle batch actor shutdown gracefully#4725
suzmue merged 1 commit intogoogleapis:mainfrom
suzmue:shutdown_actor

Conversation

@suzmue
Copy link
Copy Markdown
Collaborator

@suzmue suzmue commented Feb 18, 2026

During shutdown, tasks may be aborted in any order. This means that we cannot expect that any particular task is alive at a given time. To handle shutdown of the tasks that handle batching, we shut the publisher down completely. Any dropped receiver handles for messages that were not yet sent will receive a ShutdownError when the sender half is dropped.

Shutting down the Dispatcher completely is the cleanest way to handle this and we only expect this to come up when the whole program is shutting down or there is another serious error and we want to stop publishing to indicate that things are not in a good state to continue publishing.

Fixes #4716

@suzmue suzmue requested a review from a team as a code owner February 18, 2026 23:45
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Feb 18, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.07%. Comparing base (de64270) to head (5ec5b14).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4725      +/-   ##
==========================================
+ Coverage   95.06%   95.07%   +0.01%     
==========================================
  Files         198      198              
  Lines        7598     7598              
==========================================
+ Hits         7223     7224       +1     
+ Misses        375      374       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@PhongChuong PhongChuong left a comment

Choose a reason for hiding this comment

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

Out of curiosity, is there any good way to test this? A quick search did not yield any useful result for testing.

@suzmue
Copy link
Copy Markdown
Collaborator Author

suzmue commented Feb 19, 2026

Out of curiosity, is there any good way to test this? A quick search did not yield any useful result for testing.

Yeah I was thinking about it and I think if we mock or make an alternative implementation for the BatchActors that just gives up that would work. Will look at adding in a follow up.

@suzmue suzmue merged commit d4e0156 into googleapis:main Feb 19, 2026
35 checks passed
@suzmue suzmue deleted the shutdown_actor branch February 19, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: pubsub Issues related to the Pub/Sub API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publisher should not panic when the batch actors close

2 participants