Skip to content

fix: use ReliableClusterSend for large run events - #2323

Open
calebroseland wants to merge 4 commits into
masterfrom
MM-69386
Open

fix: use ReliableClusterSend for large run events#2323
calebroseland wants to merge 4 commits into
masterfrom
MM-69386

Conversation

@calebroseland

Copy link
Copy Markdown
Member

Summary

Playbook run websocket events serialize full or partial PlaybookRun payloads. When model.WebsocketBroadcast.ReliableClusterSend is left at its default (false), inter-node delivery uses the best-effort UDP path, which (a) caps the marshalled event at ~49077 bytes and (b) may drop events. Large runs exceed the cap, so playbook_run_updated has been silently dropped for customers and internally.

This routes the large, essential run events through new reliable poster variants that set ReliableClusterSend: true, delivering them over the reliable, TCP-backed cluster channel.

Events switched to reliable (carry full/partial PlaybookRun data):

  • playbook_run_updated (channel + per-user)
  • playbook_run_updated_incremental (channel + per-user) — ChangedFields can include full checklist/timeline/status sub-trees
  • playbook_run_created (both publish sites)

Left on best-effort (payloads well under the limit): playbook_created / playbook_archived / playbook_restored ({"teamID": id}) and the global settings_changed event.

Implementation

  • server/bot/poster.go: extracted a shared publishWebsocketEvent helper (no behavior change to existing methods) and added PublishWebsocketEventToChannelReliable / PublishWebsocketEventToUserReliable.
  • server/bot/bot.go: added both methods to the Poster interface; regenerated mock_poster.go.
  • Added server/bot/poster_test.go covering broadcast scope, the ReliableClusterSend flag per method, and the shared payload marshalling path.

Ticket Link

https://mattermost.atlassian.net/browse/MM-69386

Checklist

  • Gated by experimental feature flag
  • Unit tests updated

Playbook run websocket events (playbook_run_updated,
playbook_run_updated_incremental, playbook_run_created) serialize full
or partial PlaybookRun payloads that can exceed the ~49KB cap of the
best-effort UDP cluster path, causing events to be silently dropped for
large runs. Route these large, essential events through new reliable
poster variants that set WebsocketBroadcast.ReliableClusterSend, so they
are delivered over the reliable TCP-backed cluster channel.

Small team-scoped events (playbook created/archived/restored) and the
global settings-changed event keep the default best-effort path; their
payloads are well under the limit.

Context: /longshot MM-69386 — large/essential WS events sent reliably.
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1338398d-495f-41dd-b805-7e7e35ee0fcb

📥 Commits

Reviewing files that changed from the base of the PR and between b895441 and 20afd2f.

📒 Files selected for processing (7)
  • server/app/playbook_service.go
  • server/app/playbook_service_test.go
  • server/bot/bot.go
  • server/bot/mocks/mock_poster.go
  • server/bot/poster.go
  • server/bot/poster_test.go
  • server/config/service.go
✅ Files skipped from review due to trivial changes (1)
  • server/bot/mocks/mock_poster.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/bot/poster_test.go

📝 Walkthrough

Walkthrough

Adds reliable websocket publish methods to the Bot API, updates mocks and tests, and switches playbook and configuration websocket event broadcasts to the reliable variants.

Changes

Reliable WebSocket Publishing Across Playbook Events

Layer / File(s) Summary
Poster API and reliable publish implementation
server/bot/bot.go, server/bot/poster.go
Adds reliable websocket publish methods to Poster and Bot, refactors shared publish handling into publishWebsocketEvent, and sets ReliableClusterSend: true on the new reliable variants.
Mocks and Bot publish tests
server/bot/mocks/mock_poster.go, server/bot/poster_test.go
Adds gomock coverage for the reliable methods and adds tests for broadcast scope, reliable flag handling, and payload marshalling.
Playbook and configuration websocket call sites
server/api/playbook_runs.go, server/app/playbook_run_service.go, server/app/playbook_service.go, server/app/playbook_service_test.go, server/config/service.go
Updates playbook run, playbook lifecycle, and configuration change websocket publishing to use the reliable methods, and updates the matching playbook service test expectations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

2: Dev Review

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: routing large run events through reliable websocket delivery.
Description check ✅ Passed The description matches the changeset and accurately describes the reliable websocket delivery updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MM-69386
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch MM-69386

Comment @coderabbitai help to get the list of available commands.

@JulienTant
JulienTant requested a review from hanzei June 23, 2026 16:44
@JulienTant

Copy link
Copy Markdown
Member

/update-branch

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

LGTM 👍

@hanzei

hanzei commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

I do wonder if we should also use the reliable transport for playbook_created, playbook_archived and playbook_restored. These events happen rarely and we want to ensure they get delivered to all users, right?

Following up on review feedback: playbook_created, playbook_archived,
playbook_restored and settings_changed were left on the best-effort UDP
cluster path. Their payloads are tiny, but best-effort can drop packets
outright in HA deployments, leaving connected clients with a stale
playbook list or missed settings change. These events are rare and
essential, so deliver them over the reliable TCP-backed channel too.

Add PublishWebsocketEventToTeamReliable and
PublishWebsocketEventGlobalReliable to complete the reliable poster set,
and document the criterion (essential + low-frequency) so future
high-frequency events stay on best-effort and don't saturate the shared
reliable channel.

Context: /longshot MM-69386 — PR #2323 review (hanzei): use reliable
transport for the additional rare/essential events, not just large ones.
# Conflicts:
#	server/config/service.go
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.

4 participants