Send other client messages through the broadcast queue#2834
Merged
Conversation
gefjon
reviewed
Jun 6, 2025
gefjon
left a comment
Contributor
There was a problem hiding this comment.
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.
gefjon
approved these changes
Jun 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_queuewhile 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)tobroadcast_queue.send_client_message(sender, message).Expected complexity level and risk
sender.send_messagewhen 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.