Opened 4 weeks ago
Last modified 11 days ago
#63450 new defect (bug)
Race condition for transient with no expiration and object cache active
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 6.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Cache API | Keywords: | has-patch |
Focuses: | Cc: |
Description
When object cache is installed and is temporarily unavailable, transient values with no expiration can be obsolete.
Here is a scenario:
- No object cache active, do
set_transient( 'foo', 'bar' );
- Now activate object cache
- Do
delete_transient( 'foo' );
,foo
is deleted from the cache but not fromwp_options
table ([see]https://github.com/WordPress/wordpress-develop/blob/24dde230694b33c43c3b5e9ce87320f19d08da96/src/wp-includes/option.php#L1394) - For some reason, the transient value must change, do
set_transient( 'foo', 'baz' );
. The new value is correct in cache, but not inwp_options
table ([see]https://github.com/WordPress/wordpress-develop/blob/24dde230694b33c43c3b5e9ce87320f19d08da96/src/wp-includes/option.php#L1542). - Now let's say the cache is temporarily unavailable (update, malfunction, you name it). When doing
get_transient( 'foo' );
we get'bar'
instead of'baz'
(we expect the last value set).
If some major feature depends on this transient (e.g. rewrite rules), it can lead to weird behaviors that are hard to debug.
For the record, we encountered such a bug in Polylang ([see]https://github.com/polylang/polylang/pull/1653).
Change History (2)
Note: See
TracTickets for help on using
tickets.
As per the title, force deletion or creation of the transient in
wp_options
table when object cache is active.Preventing race condition between object cache and
wp_options
table for a transient without expiration.Trac ticket: https://core.trac.wordpress.org/ticket/63450