Skip to content

Transaction related DB errors attempt to rollback outside of a transaction and cause a fatal error #331

Description

@notr1ch

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 (matomo-org/matomo#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions