[wp-trac] [WordPress Trac] #34330: Locks API for atomic data manipulation
WordPress Trac
noreply at wordpress.org
Fri Oct 16 17:31:26 UTC 2015
#34330: Locks API for atomic data manipulation
-----------------------------+-----------------------------
Reporter: lpghatguy | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: trunk
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
I originally opened a ticket at #34304 for locking methods specifically
for post metadata. @rmccue made a note that a full-scale locking API might
be more useful than a locking API specifically for post or userdata.
I won't fully iterate over why locking is beneficial, but in short, it
prevents data races that can have bad results.
So now I'm here to propose a locking API for all sorts of things:
- Posts
- Users
- Post/User Meta
- Options
Initiailly, I proposed an API using methods like
`get_and_update_post_meta`, taking in the normal parameters for
`get_post_meta` and the like, but also taking a callback method. During
the callback, the data would be locked and only accessible from the
callback itself.
I provided a prototype implementation using MySQL's `GET_LOCK` and similar
methods; it is attached here. To scale to the full system, it would
require lock checking code in all queries reading any data, which might be
a large undertaking. I haven't researched the potential performance
implications of this, or how it would be applied to more complicated data.
Some questions I'd like to look into:
- What would a full-scope locking API look like?
- Is this feature useful for a regular WordPress site?
- Is this a problem other users have encountered?
- Does this solution scale?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34330>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list