Skip to content


Archive.php triggered multiple times simultaneously can result in mysql deadlock situation #4186

mattab opened this Issue · 2 comments

1 participant

Piwik Open Source Analytics member

looking into random failures and deadlock situations with regards to running several archive.php crons in parallel (what is done when triggering the segments to pre-archive).

The related code is at:

There is an example of travis failure showing the ENGINE INNODB STATUS with output:

From Anthon:

There are S (shared) locks and X (exclusive) locks. And there can't be simultaneous S and X locks on the same row.

The DELETE is the older transaction. It tries to acquire a X lock on each row to be deleted. Before it can complete, the SELECT sub-query -- which I believe comes from max(idarchive) -- tries to acquire a S lock on one of these locked rows.

So, it looks like advisory locks are needed to avoid this race condition.

Piwik Open Source Analytics member

In fd5111b: Refs #4186 Adding advisory locking before running the DELETE query

Piwik Open Source Analytics member

I believe this bug is fixed, the error did not happen in travis recently.

@mattab mattab added this to the 2.0 - Piwik 2.0 milestone
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.