Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#15545 closed defect (bug) (fixed)

When using a persistent cache, there is a race condition in get_metadata()

Reported by: mdawaffe's profile mdawaffe Owned by: markjaquith's profile markjaquith
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.1
Component: Cache API Keywords: has-patch
Focuses: Cc:


get_metadata() does:

update_meta_cache($meta_type, $object_id);
$meta_cache = wp_cache_get($object_id, $meta_type . '_meta');

When using a persistent cache, another process could delete the cached data between the first and second lines there, resulting in a value of false for $meta_cache.

This can cause users to be cached without meta data (rare) or get_blogs_of_user() to cache empty arrays (common).

Attached updates update_meta_cache() to always return valid (if perhaps out of date) information for all requested IDs, not just the previously uncached IDs.

Attached also uses this update to simplify get_user_metavalues().

To prevent storing out of date information, wp_cache_add() should probably be used with update_meta_cache() data (as opposed to wp_cache_set()): users, *_meta, etc. I didn't audit everything (and I'm not positive it's a concern), so this patch doesn't address the above add v. set guideline. get_blogs_of_user() should probably do an add instead of a set, though....

This patch is currently running on without problem... so far :)

Attachments (1)

15545.diff (2.0 KB) - added by mdawaffe 14 years ago.

Download all attachments as: .zip

Change History (4)

14 years ago

#1 @ryan
14 years ago

(In [16596]) Meta data caching improvements. Props mdawaffe. see #15545

#2 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

#3 @markjaquith
13 years ago

  • Owner set to markjaquith

Oops. See #15546.

Last edited 13 years ago by markjaquith (previous) (diff)
Note: See TracTickets for help on using tickets.