Skip to content

WIP: fix(pubsub): remove actors that are no longer processing messages#4897

Draft
PhongChuong wants to merge 1 commit intogoogleapis:mainfrom
PhongChuong:pubsubDeleteActor
Draft

WIP: fix(pubsub): remove actors that are no longer processing messages#4897
PhongChuong wants to merge 1 commit intogoogleapis:mainfrom
PhongChuong:pubsubDeleteActor

Conversation

@PhongChuong
Copy link
Collaborator

@PhongChuong PhongChuong commented Mar 4, 2026

The Dispatcher now removes batch_actors entries that are no longer processing messages.

A batch actor will close its channel and begin shutdown when it detects that it has no pending messages. Any remaining messages in the channel will be handled by the run loop.

When an actor shutdown, the Dispatcher joins its task and removes the entry from batch_actors. Since sequential actors requires batches to complete before the next batch can be sent, we keep a buffer of messages that arrives after the channel is closed. This buffer is passed onto the next batch actor is needed.

This PR updates 2 tests to reflect the new behavior:

  1. client::batch_sends_on_byte_threshold: don't check the number of times the rpc is performed since the actor shutdown can change how batching is performed.
  2. actor::sequential_actor_flush: don't check empty flush since it causes the actor to shutdown. Plus, the case is already covered by the test client::flush_with_no_messages_is_noop

Fixes #4012

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Mar 4, 2026
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 70.83333% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.46%. Comparing base (9fe2fd7) to head (108b38d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/pubsub/src/publisher/actor.rs 70.83% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4897      +/-   ##
==========================================
- Coverage   94.55%   94.46%   -0.10%     
==========================================
  Files         213      213              
  Lines        8378     8384       +6     
==========================================
- Hits         7922     7920       -2     
- Misses        456      464       +8     

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

@PhongChuong PhongChuong changed the title fix(pubsub): remove actors that are no longer processing messages WIP: fix(pubsub): remove actors that are no longer processing messages Mar 5, 2026
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.

Pubsub: Support message ordering in Publisher

1 participant