#64887 closed defect (bug) (fixed)
Real-time collaboration: Compaction race condition in the default polling provider
| Reported by: | czarate | Owned by: | ellatrix |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.0 |
| Component: | REST API | Version: | 7.0 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
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.
4 months ago
#1
- Keywords has-patch has-unit-tests added
@czarate commented on PR #11292:
4 months ago
#3
Closing since this change has been committed.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.