[wp-trac] [WordPress Trac] #63450: Race condition for transient with no expiration and object cache active
WordPress Trac
noreply at wordpress.org
Wed Jun 4 10:32:21 UTC 2025
#63450: Race condition for transient with no expiration and object cache active
--------------------------+---------------------
Reporter: hugod | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.9
Component: Cache API | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+---------------------
Comment (by logicrays):
### ✅ Solution for Ticket: *Race condition for transient with no
expiration and object cache active*
The root issue is that when a **persistent object cache is enabled**,
transients **without expiration** are only stored in the cache and not
reliably cleaned from the database (`wp_options`). This causes
**inconsistent values** when the object cache is temporarily unavailable.
---
### 🔧 Solution (in 5–6 lines):
To resolve this, ensure `delete_transient()` **always deletes from both**
the object cache and the `wp_options` table, even if the transient has no
expiration. Additionally, `set_transient()` should **synchronize the
database value** if no expiration is set or if the object cache is
unavailable. Core logic should include fallback checks and ensure
consistency between cache and database, especially when the cache layer is
unstable or offline. This prevents stale values from being loaded and
avoids hard-to-debug behavior in dependent features like rewrite rules.
Let me know if you'd like a patch example or test case for core.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63450#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list