Skip to content

Send other client messages through the broadcast queue#2834

Merged
jsdt merged 3 commits into
phoebe/clients-map-two-copiesfrom
jsdt/broadcast-queue
Jun 6, 2025
Merged

Send other client messages through the broadcast queue#2834
jsdt merged 3 commits into
phoebe/clients-map-two-copiesfrom
jsdt/broadcast-queue

Conversation

@jsdt

@jsdt jsdt commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

Description of Changes

For context, there is a discussion of potential race conditions here.

The short explanation is that to make sure clients see things in a consistent order, we need to add outgoing messages to the broadcast_queue while we are still holding the associated database transaction lock.

I still need to do this for one-off queries.
This still has an issue with one-off queries, since I haven't routed those messages through.

The change is mostly a matter of changing code like sender.send_message(message) to broadcast_queue.send_client_message(sender, message).

Expected complexity level and risk

  1. I don't have a good idea for how to prevent people from accidentally calling sender.send_message when they should be using the broadcast queue, so some bugs might creep back in over time.

Testing

So far I gave this a very basic test with the quickstart-chat app locally.

@jsdt jsdt requested review from Centril and gefjon as code owners June 5, 2025 18:20

@gefjon gefjon 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.

I don't have a good idea for how to prevent people from accidentally calling sender.send_message when they should be using the broadcast queue, so some bugs might creep back in over time.

A doc comment on send_message instructing readers to use the broadcast queue instead seems like a good place to start.

Comment thread crates/core/src/subscription/module_subscription_actor.rs Outdated
@jsdt jsdt merged commit 9eaec03 into phoebe/clients-map-two-copies Jun 6, 2025
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants