Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
mattab opened this Issue · 2 comments

1 participant

Matthieu Aubry
Matthieu Aubry
Owner

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: https://github.com/piwik/piwik/blob/master/core/DataAccess/ArchiveWriter.php#L95

There is an example of travis failure showing the ENGINE INNODB STATUS with output:
https://travis-ci.org/piwik/piwik/jobs/11862693

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.

Matthieu Aubry
Owner

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

Matthieu Aubry
Owner

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

Matthieu Aubry 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.