#64887 closed defect (bug) (fixed)
Real-time collaboration: Compaction race condition in the default polling provider
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| 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:
- https://github.com/WordPress/wordpress-develop/blob/8a82e67cf65766fcb8a11e3fe5c6e2f48083fcdb/src/wp-includes/collaboration/class-wp-sync-post-meta-storage.php#L305
- https://github.com/WordPress/wordpress-develop/blob/8a82e67cf65766fcb8a11e3fe5c6e2f48083fcdb/src/wp-includes/collaboration/class-wp-sync-post-meta-storage.php#L308
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
#2
@
11 days ago
- Owner set to ellatrix
- Resolution set to fixed
- Status changed from new to closed
In 62064:
@czarate commented on PR #11292:
10 days ago
#3
Closing since this change has been committed.
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.