Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#331 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@snake14 已经在做这个了。

开始于 2026年10月14日。

  • #348 来自 @snake14 —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
mariadb, php
领域
backend, databases

调研方向

从 Mysql.php 约第 411 行开始,跟踪 Queued Tracking 用于处理事务相关数据库错误的 onException 处理逻辑。检查错误状态和 rollback 是如何触发的,然后验证在不再存在事务时,诸如 1020 之类的可重试错误不会导致致命的 rollback。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
PHP
星标
87
派生
42
平均合并
2 天 8 小时
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

matomo-org/plugin-QueuedTracking 的其他 Issue

查看 matomo-org/plugin-QueuedTracking 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。