Repository navigation
Description
Summary
Concurrent UPDATE ... SET embedding=... on IVF-indexed tables triggers deadlock detected (20701) at a ~39% failure rate in the stability test update_embedding scenario. This is a confirmed regression on 4.2-dev between Jul 28 and Aug 4, 2026.
Impact
- Severity: S1 — IVF vector index updates are unusable under concurrent workload
- Affected branch:
4.2-dev(also affectsmainsince Jul 28, but with different onset pattern) - Failure rate: 39.4% of all IVF UPDATE operations fail with deadlock
- No data corruption — panics=0, consistency checks pass
Reproduction
The stability test ivf_dml_scenarios.py scenario update_embedding reproduces this 100%:
-- Table: test_vectors with ivfflat index (lists=10, dim=128)
-- 8 concurrent updater workers:
UPDATE test_vectors SET embedding = <new_vector>, content = <new_content> WHERE id = <existing_id>
-- 8 concurrent searcher workers:
SELECT id, content, L2_DISTANCE(embedding, <query_vector>) AS l2_dist
FROM test_vectors
WHERE user_id = <uid> AND is_active = 1 AND mtype = 'profile'
AND embedding IS NOT NULL AND id != <exclude_id>
ORDER BY l2_dist ASC LIMIT 1Minimal repro: 2+ sessions concurrently updating the embedding column of an IVF-indexed table on different rows.
Regression Timeline
| Run | Branch | Date | Updates | Errors | Rate | Deadlock? |
|---|---|---|---|---|---|---|
29066558663 |
main | Jul 10 | 62K | 3 | 0.005% | ❌ |
29976993561 |
4.2-dev | Jul 23 | 13K | 0 | 0% | ❌ |
30325776224 |
4.2-dev | Jul 28 | 388K | 72 | 0.02% | ❌ |
30327129762 |
main | Jul 28 | 323K | 20K | 6.3% | ✅ (from round 16,582) |
30876385810 |
4.2-dev | Aug 4 | 101K | 33K | 32.7% | ✅ (from round 1) |
31405643514 |
4.2-dev | Aug 10 | 43K* | 17K | 39.4% | ✅ (from round 1) |
*still running at round 14,736/86,400
Key observations:
- 4.2-dev Jul 28 was clean — 388K updates with only 72 non-deadlock errors (0.02%)
- 4.2-dev Aug 4 broke immediately — deadlock from round 1, first error is
(20701, deadlock detected) - main Jul 28 has the bug too but with gradual onset (starts at round 16,582 after a CN fault event)
- DELETE is unaffected —
delete_rowsscenario: 167K deletes, 0 errors
Error Details
Error type: 100% (20701, 'deadlock detected') — no other error types in 4.2-dev Aug 4+
Worker distribution (4 updaters, roughly equal):
u0: failures=17,101
u1: failures=16,401
u2: failures=16,501
u3: failures=17,001
Error rate over rounds (stable at ~39%, not growing):
round 100: 321 updates, 83 errors → 25.9%
round 1000: 2978 updates, 1062 errors → 35.7%
round 5000: 14721 updates, 5632 errors → 38.3%
round 14736: 43233 updates, 17034 errors → 39.4%
Server-Side Evidence (CN Pod Logs)
// CN-1: deadlock detected on UPDATE statement
{"level":"ERROR","msg":"deadlock detected",
"statement":"UPDATE test_vectors SET embedding='[0.3637,...]' ...",
"caller":"frontend/session.go:2433"}
// CN-2: lock service confirms dead lock
{"level":"INFO","msg":"dead lock found",
"caller":"lockservice/log.go:458"}
// CN-1: remote lock acquisition fails
{"level":"ERROR","msg":"failed to lock on remote",
"caller":"lockservice/log.go:285"}
// CN-2: local lock acquisition canceled
{"level":"ERROR","msg":"failed to lock on local",
"opts":"Exclusive-Row-Wait","error":"context canceled"}The deadlock involves both CN pods — one CN holds a local lock and waits for a remote lock on the other CN, while the other CN holds that remote lock and waits for the first CN's local lock, forming a circular wait.
Two Onset Patterns
Pattern A — 4.2-dev Aug 4+ (immediate):
- Deadlock from round 1, no triggering event needed
- Suggests a structural code bug in the IVF UPDATE lock acquisition path
- ~39% stable failure rate
Pattern B — main Jul 28 (gradual):
- Clean for 16,581 rounds, then triggered by a CN fault event:
① (20505) cannot connect to backend: none ② (1205) Lock wait timeout exceeded ③ (20702) lock table bind changed ← key: lock table state corrupted ④ (20701) deadlock detected ← deadlock starts after this - After CN fault, deadlock accumulates gradually to 6.3%
- Suggests the CN fault leaves the IVF lock state inconsistent
Bisect Window
4.2-dev: Commits between 2026-07-28 (clean, commit 6004bec area) and 2026-08-04 (broken, commit fa6c57c)
The regression may involve:
- A main → 4.2-dev merge that brought in the lock issue
- An overwrite/revert of the fix that kept 4.2-dev clean on Jul 28
- Changes to
lockservice, IVF index UPDATE path, or txn lock ordering
Environment
- Cluster: 7-pod distributed (2CN + 1DN + 3Log + 1Proxy)
- Test:
dml-vector-test/mo-nightly-regression/script/ivf_dml_scenarios.py - Namespace:
mo-stb-4-2-dev-b83878b-202608102354 - Runner:
mo-sta-128 - MO image:
commit-b83878b(4.2-dev)
Affected Test Items
Only update_embedding scenario is affected. Other DML scenarios pass:
- ✅
insert_l2: 0 panics, 0 errors in 1.1M searches + 1.5M inserts - ❌
update_embedding: 39.4% deadlock rate - ⏳
delete_rows: not yet reached (blocked by update_embedding)
Activity
[4.2] fix(lockservice): exclude uncertain locks from deadlock graph (#…
LeftHandCold commentedon Aug 14, 2026
Follow-up root-cause split:
T <= Tself-cycle caused by uncertain cleanup-only remote locks.LOCK_OP, allowing the baseMULTI_UPDATEbranch and IVF hidden-table maintenance branches to acquire locks in opposite orders.This separates the two failure classes covered by the original issue and gives each one a deterministic regression.
fix(plan): lock base rows before irregular update fanout (#27144)
Ariznawlll commentedon Aug 17, 2026
08-17 更新:main 已稳定,4.2-dev 再次复现
main 分支 (run 31813395380, 08-14 启动)
DML Vector 测试连续运行 3 天,errors 全 0,deadlock 未复现:
4.2-dev 分支 (run 31813474502, 08-14 启动)
08-16 白天 DML Vector 一度正常(errors=0),但在某次 CN 瞬时故障(连接被拒绝)后,进程重启(round 从 64,637 回退到 6,452),deadlock 再次以渐发型模式出现:
CN Pod 日志确认错误类型仍为
deadlock detected (20701):与之前观察到的 4.2-dev 渐发型模式一致:CN 故障导致锁状态不一致后,deadlock 开始累积。
总结
main 上的修复(如果有)似乎有效,但 4.2-dev 仍未解决。
[4.2] fix(plan): lock base rows before irregular update fanout (#27222)
Ariznawlll commentedon Aug 20, 2026
验证结论
4.2-dev 当前部署版本为
e9d53c4997e3e022df5aedc3795f16d9739b4aae,已包含修复 PR #27222(commit7df82923dfb69de157916e86ce4b3f42cc6b824d)。在 128 稳定性环境
mo-stb-4-2-dev-aaac595-202608142318上核验:修复版本运行超过 18 小时,两个 CN 日志中deadlock detected为 0,未发现 panic。DML Vector 的 round、search 和 update 均持续增长,errors(update)未再增加;日志中的 12285 是旧镜像及滚动更新期间的历史累计值。原问题未再复现,测试通过,关闭 issue。
fix(plan): lock base rows before irregular update fanout (matrixorigi…
fix(plan): lock base rows before irregular update fanout (matrixorigi…
fix(plan): lock base rows before irregular update fanout (matrixorigi…