Repository navigation
Retry a request set whose transaction was rolled back by a caught error - #356
Conversation
A tracking step can catch an error after which the database already rolled back the transaction; the set now goes down the retry path, and a failed run rolls back before releasing its lock.
ed34465 to
0079917
Compare
PHPStan runs against released Matomo, which has no TransactionErrors class or TRANSACTION_ABORTED_MESSAGE yet.
snake14
left a comment
There was a problem hiding this comment.
The fix works: a deadlock swallowed on the last request of a batch is now retried, the lock is released, and every request is stored once, with both PDO and MYSQLI. A few things to check:
Medium
The rollback added to
Processor::process()'s catch block has no test, so removing or reordering it beforeunlock()would leave the suite green. AProcessorTestcase that makes a backend query fail on an aborted transaction and asserts the lock is released would cover it.Low
failIfTransactionAborted()always says "MySQL error 1213", even when the swallowed error was another one that ends the transaction, and that message goes to the warning log. A neutral message ("a caught error already rolled back this transaction") with the same code would avoid misleading triage.- The docblocks of
hasTransactionErrors(),getRequestSetsWithTransactionErrors()andisRetryableTransactionError()still describe the old set of errors.
Adds a ProcessorTest case that fails if the aborted transaction is not rolled back before the lock is released, and updates the docblocks to the new error set.
A request that swallowed a deadlock and was then rejected as invalid or for an unknown site left the set counted as processed.
|
@snake14 Should be good to be re-reviewed now |
snake14
left a comment
There was a problem hiding this comment.
Thanks for the changes @chippison . It looks like we missed the automated release for this week. Can you please merge in the base and bump the plugin.json/changelog version?
|
AI also mentioned few things to check. One is the version bump which I requested:
|
…ze-transaction-rollback-handling
6.0.3 was released without it.
The rollback before unlocking is now tested through a deadlock in the lock query, the path still left for it.
|
@snake14 |
snake14
left a comment
There was a problem hiding this comment.
Works as expected. All review points have been addressed. Thank you. 👍
DEV-20866
Follow-up to matomo-org/matomo#25549, which makes the tracker connection refuse every query and the commit after an error that rolled back the transaction.
If a tracking step caught such an error on the last query of a request set, nothing noticed until the lock or commit queries, which then failed outside the retry path. The worker crashed, and the unlock in the error handler failed too, so the lock stayed held until it expired.
TransactionErrorswhen it exists.Both checks are skipped on Matomo versions without the core change. The new
HandlerTestcase needs the core PR, and is skipped without it.Review