New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to prevent possible deadlock in archive invalidator #15603
Conversation
core/Archive/ArchiveInvalidator.php
Outdated
// we want to reduce number of rows scanned and only delete specific primary key | ||
$keys = Option::getLike($id . '%'); | ||
foreach ( $keys as $key => $val) { | ||
Option::delete($key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to do a DELETE FROM option WHERE option_name IN (...)
so it's just one query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diosmosis was thinking about it but then figured it's easier to just reuse existing code for now. Not sure it makes a big difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it depends on how many invalidated dates there can usually be at one time for a single site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be too many since we regenerate the tracker cache once the flag is written to avoid another request to set this flag? could be a few if there were many requests in parallel maybe. I'll try to have a look but don't really have time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it @diosmosis
…5603) * Try to prevent possible deadlock in archive invalidator * use one query to delete all at once
…5603) * Try to prevent possible deadlock in archive invalidator * use one query to delete all at once
See http://mitchdickinson.com/mysql-innodb-row-locking-in-delete/
The idea is that if we delete by primary key, then no other rows will be locked thus avoiding the deadlock hopefully. For deadlock info see #15545 (comment) and below.
Checked other Option::deleteLike but they seem fine.
fix #15545
Be great if that could make it into 3.13.3 since we would likely be facing these issues a lot too.
I haven't tested if it actually prevents the deadlock but hoping so. We will otherwise need to reopen #15545 if it doesn't.
Background: When we set an option, we set basically
$id_$processId
. So this should prevent the lock when we delete the key directly by primary key since the appendix_$processId
should be different and not prevent the insertion of another key.