[5.x]: Product save causes long-running queries leading to minutes-long hangs
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 冷清
- 技术栈
- mariadb, mysql, php
- 领域
- backend, databases, performance
调研方向
首先重现远程 Commerce 产品保存操作,并检查 elements/apply-draft 请求。跟踪 GET_LOCK() 周围的 Product::afterPropagate()、Revisions::createRevision() 和 MysqlMutex,同时比较 MySQL 与 MariaDB 中 SHOW FULL PROCESSLIST 里的卡住的 elements SELECT。完成的标准是找出原因,并验证保存操作能够按预期完成,不会出现长时间运行的查询或 Server has gone away 错误。
由索引模型根据 Issue 内容生成。
描述
What happened?
Description
On our staging/production environment, saving a Commerce product from the control panel can take many minutes, the CP appears to hang, and the front of the site is hard to reach while the save is in progress. In the queue we see jobs such as “Generating catalog pricing” and “Updating search indexes”, but profiling suggests the real bottleneck is long-running MySQL work, not those jobs completing slowly in isolation.
On local (DDEV) with the same project, product saves complete in a reasonable time.
We traced two concrete failure modes:
-
SQLSTATE[HY000]: General error: 2006 Server has gone awayduringelements/apply-draft. The stack shows the failure when acquiring a DB mutex / revision work (GET_LOCKviaMysqlMutex) afterProduct::afterPropagate()→Revisions::createRevision(), consistent with the DB connection being dropped mid-request (e.g. serverwait_timeoutvs a very long apply/save). -
SHOW FULL PROCESSLISTrepeatedly shows the sameSELECTonelements(columns such asid,canonicalId,fieldLayoutId,uid, …) stuck inStatisticsfor hundreds to thousands of seconds. Several such connections can pile up at once.
We have used KILL on stuck connections. Local DB is MySQL 8; server is MariaDB 10.6, so optimizer behavior may differ from dev even with identical code.
We have some fields coming from plugins in the products, so I tried to remove them, but still no luck. We don't have a lot of products and variants (~75 total).
I've seen others issues like this one but we still have the problem. Everything is up to date.
Steps to reproduce
- Open the control panel on a remote environment.
- Edit a Commerce product.
- Click Save.
- CP and site are now stuck.
Expected behavior
Product save should complete in a short, predictable time, without blocking the site for minutes, and without MySQL sessions stuck during normal saves.
Actual behavior
- Save take minutes; CP and site feel blocked for other users.
- DB may show multiple long-lived
SELECT … elements …queries inStatistics, or2006 Server has gone awayduringapply-draft/ revision-related steps.
Craft CMS version
5.9.17
Craft Commerce version
5.6.1
PHP version
8.2.30
Operating system and version
Linux 4.18.0-553.89.1.lve.el8.x86_64
Database type and version
MariaDB 10.6.24
Image driver and version
GD 8.2.30
Installed plugins and versions
- CKEditor 5.3.1
- Neo 5.5.7
- SEO 5.0.0
- Moneris for Craft Commerce 1.0.0 (custom payment gateway by us)
- 主要语言
- PHP
- 星标
- 242
- 派生
- 172
- 平均合并
- 21 小时 23 分钟
- 30 天内合并 PR
- 76
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
craftcms/commerce 的其他 Issue
-
[5.x]: `getInventoryLevel()` reads every inventory transaction of the location to return one item未关闭bug commerce5 Craft Commerce repo:commerce
难度 4/5 1-2 天 新手友好度 55/100
craftcms/commerce#4494 · 2 条评论 ·
维护者通常 1 天内回复
-
[6.x]: Commerce can't boot without `craftcms/yii2-adapter`可能重新可做 @lukeholder 于 30 天前认领,目前没有进行中的 PR。 未关闭repo:commerce
难度 4/5 3-5 天 新手友好度 45/100
craftcms/commerce#4402 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[5.x]: Catalog pricing queue lock is held until the product save commits, so parallel saves run one at a time可能已有人在做 @nfourtythree 于 30 天前认领。 未关闭repo:commerce
难度 4/5 3-5 天 新手友好度 48/100
craftcms/commerce#4389 · 3 条评论 ·
维护者通常 1 天内回复
-
💡 enhancement commerce5 Craft Commerce
难度 4/5 3-5 天 新手友好度 35/100
craftcms/commerce#4156 · 1 条评论 ·
维护者通常 1 天内回复
-
[4.x]: Multiple empty carts when refreshing fast with autoSetNewCartAddresses setting可能重新可做 @lukeholder 于 596 天前认领,目前没有进行中的 PR。 未关闭bug commerce4 Craft Commerce
craftcms/commerce#3973 · 6 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 craftcms/commerce 的全部 Issue
相似的 Issue
-
Document lexicon.default.userconfig and lexicon.default.userconfig.enforced in config.sample.php未关闭enhancement feature: settings good first issue
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
nextcloud/integration_openai#480 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
a11y
难度 2/5 1-3 小时 新手友好度 68/100
omeka/plugin-Contribution#84 ·
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
recca0120/vscode-phpunit#620 ·
维护者通常 1 天内回复