Skip to content

[core] Assert Pub-Sub channel subscription counts to avoid unexpected increases - #65148

Merged
sampan-s-nayak merged 12 commits into
ray-project:masterfrom
sampan-s-nayak:pubsub-channel-subscription-stats
Aug 24, 2026
Merged

sampan-s-nayak merged 12 commits into
ray-project:masterfrom
sampan-s-nayak:pubsub-channel-subscription-stats

Conversation

@sampan-s-nayak

@sampan-s-nayak sampan-s-nayak commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

Regression test to prevent cases like the one identified in #63310 where every worker ended up subscribing to worker death notifications from every other worker.

we assert the following to be true during ray cluster startup:

channel connections
GCS_WORKER_DELTA O(num_nodes)
GCS_JOB O(num_nodes)
GCS_ACTOR all actor events <= 1, keyed (actor_id) specific events >= 1
GCS_NODE_ADDRESS_AND_LIVENESS no keyed(node_id) listeners

…te and add worker-death fan-out regression test

Signed-off-by: sampan <[email protected]>
@sampan-s-nayak sampan-s-nayak changed the title [core] Expose per-channel pubsub subscription counts in GCS debug state + O(nodes) worker-death fan-out regression test [core] Assert Pub-Sub channel subscription counts to avoid unexpected increases Jul 31, 2026
result << "Publisher:";
for (const auto &it : cum_pub_message_count_) {
auto channel_type = it.first;
// Iterate the subscription indexes (one per registered channel) rather

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

as we only have around 8 channels ( GCS publisher registers 5 channels (actor, job, node-info, worker-delta, node-liveness) and the observability publisher 3 (error, log, resource-usage). I am hoping this does not get too spammy (and I guess these channels would eventually show up in the logs so logging them before first publish should still be ok.

also knowing subscriber counts would be useful info for debugging

Signed-off-by: sampan <[email protected]>
@sampan-s-nayak
sampan-s-nayak marked this pull request as ready for review August 6, 2026 03:32
@sampan-s-nayak
sampan-s-nayak requested a review from a team as a code owner August 6, 2026 03:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a new test to assert that pub-sub channel subscriptions remain bounded, and updates the GCS publisher's debug string output to iterate over registered subscription channels rather than cumulative publish counters, ensuring all active channels are reported. The review feedback highlights two important issues: a potential FileNotFoundError in the test if the log file is not yet created when check() is first executed, and a potential null pointer dereference in publisher.cc if FindValueByNumber returns nullptr for an invalid channel type.

Comment thread python/ray/tests/test_gcs_pubsub.py Resolved
Comment thread src/ray/pubsub/publisher.cc Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 83f312f. Configure here.

Comment thread src/ray/pubsub/publisher.h Resolved
@ray-gardener ray-gardener Bot added the core Issues that should be addressed in Ray Core label Aug 6, 2026
sampan-s-nayak and others added 3 commits August 7, 2026 07:37
- Force distinct worker processes with a SignalActor barrier instead of
  relying on Ray to spread 12 short tasks over >=4 workers, which failed
  in CI when only 2 workers were reused.
- Harden the GCS log parse: tolerate the log not existing yet and read it
  as utf-8.
- Use rpc::ChannelType_Name in Publisher::DebugString instead of
  dereferencing the descriptor lookup, which can return nullptr.
- Add missing Doxygen @return tags on the new SubscriptionIndex getters.

Signed-off-by: sampan <[email protected]>
@rueian

rueian commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

The DebugString and test changes LGTM. Are we going to do another gRPC connection count assertion?

The keyed number reported per channel counts entity *keys*, not
subscribers, so N workers all watching the same key showed up as
keys=1 and would have slipped through. Add:

- SubscriptionIndex::GetNumKeyedSubscribers() (subscribers_to_key_id_
  size), reported per channel, so keyed subscriptions that scale with
  the number of workers are visible.
- A publisher-level long-polling subscriber count. There is one
  long-poll connection per subscriber process per publisher,
  multiplexed over every channel and key, so this is the connection
  count and it is channel-agnostic.

The test parses per-publisher blocks now, since the GCS dumps both its
own publisher and the observability publisher into one debug block.

Also swap the worker barrier from a SignalActor to a shared directory:
a worker holding an actor handle subscribes to that actor's key on
GCS_ACTOR_CHANNEL and to node liveness, which made those counts scale
with num_workers and masked what the test guards. With the actor-free
barrier every asserted count is unchanged at num_workers=6 and 12.

Signed-off-by: sampan <[email protected]>
Signed-off-by: sampan <[email protected]>
Comment thread python/ray/tests/test_gcs_pubsub.py Resolved
Comment thread src/ray/pubsub/publisher.cc Resolved
Comment thread python/ray/tests/test_gcs_pubsub.py Resolved
Co-authored-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
@sampan-s-nayak
sampan-s-nayak enabled auto-merge (squash) August 24, 2026 17:37
@sampan-s-nayak
sampan-s-nayak merged commit 57b02f9 into ray-project:master Aug 24, 2026
7 checks passed
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
… increases (ray-project#65148)

## Description

Regression test to prevent cases like the one identified in
ray-project#63310 where every worker ended
up subscribing to worker death notifications from every other worker.


we assert the following to be true during ray cluster startup:

| channel | connections|
| -------- | -------- | 
| GCS_WORKER_DELTA    | O(num_nodes)  | 
| GCS_JOB    | O(num_nodes)  | 
| GCS_ACTOR | all actor events <= 1, keyed (actor_id) specific events >=
1 |
| GCS_NODE_ADDRESS_AND_LIVENESS| no keyed(node_id) listeners |

---------

Signed-off-by: sampan <[email protected]>
Signed-off-by: Rueian <[email protected]>
Co-authored-by: sampan <[email protected]>
Co-authored-by: Rueian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants