matomo-org / matomo-org/plugin-QueuedTracking
Transaction related DB errors attempt to rollback outside of a transaction and cause a fatal error
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 87
- Forks
- 41
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 7
Description
If an innodb_snapshot_isolation or similar transaction-related DB exception occurs during processing, Queued Tracking attempts to roll back but there's no transaction any more - the DB has already aborted the transaction, so this throws a fatal error and causes unwanted side effects such as site-wide cache destruction (https://github.com/matomo-org/matomo/issues/25000).
Starting to process request sets, this can take a while
Error query: Error query: SQLSTATE[HY000]: General error: 1020 Record has changed since last read in table 'matomo_log_visit'; try restarting transaction In query: UPDATE matomo_log_visit SET profilable = ?, visitor_seconds_since_order = ?, visit_exit_idaction_name = ?, visit_exit_idaction_url = ?, visit_total_actions = visit_total_actions + 1 , visit_total_interactions = visit_total_interactions + 1 , visit_total_time = ? WHERE idsite = ? AND idvisit = ? Parameters: array (
0 => 1,
1 => NULL,
2 => 200127,
3 => 200128,
4 => 952,
5 => 1,
6 => 1234653346,
) In query: UPDATE matomo_log_visit SET profilable = ?, visitor_seconds_since_order = ?, visit_exit_idaction_name = ?, visit_exit_idaction_url = ?, visit_total_actions = visit_total_actions + 1 , visit_total_interactions = visit_total_interactions + 1 , visit_total_time = ? WHERE idsite = ? AND idvisit = ? Parameters: array (
0 => 1,
1 => NULL,
2 => 200127,
3 => 200128,
4 => 952,
5 => 1,
6 => 1234653346,
)
In Mysql.php line 411:
There is no active transaction
It would be good to add 1020 to onException so it at least gets retried (MariaDB LTS has innodb_snapshot_isolation on by default), but attempting to rollback outside of the transaction is still fatal - this is already the case with InnoDB deadlocks and other transaction related errors. I would suggest catching a rollback with no active transaction error and make it a no-op as the current logic always sets $this->hasError = true even if it's a retriable transaction error, so rollbacks are triggered regardless.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Mysql.php around line 411 and trace the onException handling used by Queued Tracking for transaction-related database errors. Check how error state and rollback are triggered, then verify that retryable errors such as 1020 do not cause a fatal rollback when no transaction remains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mariadb, php
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100