Make WordPress Core

Opened 12 days ago

Closed 11 days ago

Last modified 9 days ago

#64887 closed defect (bug) (fixed)

Real-time collaboration: Compaction race condition in the default polling provider

Reported by: czarate's profile czarate Owned by: ellatrix's profile ellatrix
Milestone: 7.0 Priority: normal
Severity: normal Version: trunk
Component: REST API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

There is a race condition in the post meta storage engine (WP_Sync_Post_Meta_Storage) for the default RTC polling provider.

When handling compaction updates, all updates for a room are deleted before being partially restored along with the compaction update. The race condition is between these two lines:

In other words, while Client A is performing compaction, Client B could contribute an update that gets lost because it is not in Client A's in-memory copy of the update set.

Instead of using WordPress functions, we can use post meta meta_ids as cursors and conduct direct DELETE queries.

Incidentally, moving to meta_id cursors also fixes a bug with 32-bit PHP. The current timestamp-based cursors exceed 32-bit integer space.

Props to @mindctrl and @JoeFusco for spotting the race condition and exploring fixes.

Change History (4)

This ticket was mentioned in PR #11292 on WordPress/wordpress-develop by @czarate.


12 days ago
#1

  • Keywords has-patch has-unit-tests added

Fix race condition in RTC default polling provider. This solution is pulled from @mindctrl's PR https://github.com/WordPress/wordpress-develop/pull/11067

This PR is targeted as narrowly as possible at the solving the race condition and does not attempt to solve the cache invalidation issues. If https://github.com/WordPress/wordpress-develop/pull/11290 is merged, then we can consider it solved separately.

This race condition is also solved by @josephfusco's PR https://github.com/WordPress/wordpress-develop/pull/11256 to replace post meta storage with a dedicated table. If that PR is merged, this one can be closed.

#2 @ellatrix
11 days ago

  • Owner set to ellatrix
  • Resolution set to fixed
  • Status changed from new to closed

In 62064:

Real-time collaboration: fix race condition in default polling provider.

See also: https://github.com/WordPress/wordpress-develop/pull/11067.
Developed in: https://github.com/WordPress/wordpress-develop/pull/11292.

Fixes #64887.
Props czarate, westonruter, mindctrl, peterwilsoncc, joefusco.

@czarate commented on PR #11292:


10 days ago
#3

Closing since this change has been committed.

#4 @sabernhardt
9 days ago

  • Milestone changed from Awaiting Review to 7.0
Note: See TracTickets for help on using tickets.