Skip to content

feat: pubsub reports dropped messages #7660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 25, 2023
Merged

Conversation

spikecurtis
Copy link
Contributor

prerequisite for #7371 and #7295

When the pubsub loses database connection (e.g. due to network hiccup), subscribers might miss messages. This currently happens silently, which is bad for applications that use the pubsub as a dependable communication, rather than just a kick to query the database for updates.

This PR enhances the Pubsub to be able to report when messages might have been dropped, so that applications can take some action. In the case of streaming build logs, we'll probably just give up and propagate the error to the HTTP requestor. In the case of the tailnet coordinator, it means we need to resync state.

Signed-off-by: Spike Curtis <spike@coder.com>
Signed-off-by: Spike Curtis <spike@coder.com>
Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

The code looks super well tested and good to me.

I think separating the in-memory implementation could be wise now that there's sufficient complexity in making it proper.

Comment on lines +35 to +39
// msgOrErr either contains a message or an error
type msgOrErr struct {
msg []byte
err error
}
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts on moving the in-memory pubsub to its own package? I feel like I made a mistake bundling it inside database when I created it, and this seems like an opportunity to fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to move it, but probably will open a separate PR. Where do you think it should go? subpackage of database?

We could move the interface & in-memory pubsub to coderd/pubsub?

Signed-off-by: Spike Curtis <spike@coder.com>
@spikecurtis spikecurtis enabled auto-merge (squash) May 25, 2023 05:51
Signed-off-by: Spike Curtis <spike@coder.com>
@spikecurtis spikecurtis merged commit 67cc196 into main May 25, 2023
@spikecurtis spikecurtis deleted the spike/pubsub-msg-loss branch May 25, 2023 06:22
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants