Sync: Add cron cleanup for stale CRDT document post meta#75466
Sync: Add cron cleanup for stale CRDT document post meta#75466
Conversation
|
Flaky tests detected in 2d3275b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/21945161833
|
|
Hi @pkevan, I've updated the issue with clarification. Our target should not be the Our targets are the sync updates generated by the default sync provider, which are also separately stored in post against a special post type. |
Thanks - I got confused here! I've updated the PR description to reflect the change in functionality based on this. |
Introduces a daily WP-Cron event that removes stale sync_update_* and sync_awareness_* post meta from the wp_sync_storage post. Each update envelope's timestamp is checked against a configurable expiration period (default 7 days via wp_sync_cleanup_expiration filter). The cron event is unscheduled on plugin deactivation.
6e87805 to
5cc4c0b
Compare
What?
Closes #75311
Adds a daily WP-Cron event that cleans up stale
syncpost meta left behind by real-time collaboration sessions.Why?
When real-time collaboration sessions end (e.g. browser closed, network lost),
sync_awareness_andsync_update_post meta can be left behind indefinitely. Over time this can accumulate unnecessary data in the database.How?
A new
Gutenberg_Sync_Cleanupclass registers a daily cron event (wp_sync_cleanup) that:sync_metawp_sync_cleanup_expiration, deletes the relevant meta values.The expiration period is configurable via the
wp_sync_cleanup_expirationfilter. The cron event is properly unscheduled on plugin deactivation.Testing Instructions
wp_next_scheduled( 'wp_sync_cleanup' )returns a timestampdo_action( 'wp_sync_cleanup' )sync_meta removedsync_metaphpunit phpunit/experimental/class-gutenberg-sync-cleanup-test.php