RTC: Restore on failed request with compaction update#76872
Open
chriszarate wants to merge 1 commit intotrunkfrom
Open
RTC: Restore on failed request with compaction update#76872chriszarate wants to merge 1 commit intotrunkfrom
chriszarate wants to merge 1 commit intotrunkfrom
Conversation
|
Size Change: +15 B (0%) Total Size: 7.73 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in b15a965. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23671818006
|
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.
What?
When an RTC polling request fails, convert queued updates into a compaction update instead of replaying them.
Why?
In at least one instance, we have observed a cascading failure that results in thousands of duplicate updates, eventually resulting in OOM errors. This appears to happen when the server request fails after it successfully writes the provided updates—either because of an unknown code failure or because of a timeout or other transport issue.
When this happens, the client detects the failure and restores the updates to the queue. The exact same updates are then sent on the following poll request.
If this pattern repeats, updates are continuously duplicated leading to unbounded growth of sync data and eventual OOM errors.
How?
Instead of blindly replaying updates on failure, we must accept the possibility that the updates were successful.
This PR replaces the queue
restore()strategy with compaction: instead of re-sending the updates, the client encodes its full document state as a single compaction update and clears the queue. This is safe because:When
endCursoris still0(no successful poll yet), we fall back torestore()since the queue only contains the initialsync_step1update and there’s no meaningful document state to compact. Additionally, compaction updates require anendCursorso that they target existing updates.In theory, it's still possible for this issue to manifest on the very first poll request that contains updates, but the risk should be dramatically reduced.