DB Sync: rejected duplicate-order repairs regenerate indefinitely and accumulate failed transactions
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 18/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- clojure, javascript, sqlite
调研方向
Start in frontend.worker.sync.apply-txs/rollback-and-mark-failed-txs! and repair-applied-txs! (with sync-fix-tx-meta), which regenerate a fresh-UUID :fix transaction after each rejection, then logseq.db-sync.order/fix-duplicate-orders!. Run the isolated DataScript replay from the issue to see the rollback→repair→rejection loop. Done means repeated rejection stops generating equivalent repairs and failed rows stop growing while pending user edits are preserved.
由索引模型根据 Issue 内容生成。
描述
Search first
- I searched and no similar issues were found
Searched logseq/db-test, logseq/logseq, and the Logseq Forum for transaction rejection, duplicate orders, and repair loops. Related rejection reports include #775 and #789, but neither documents the rollback → equivalent repair with a new UUID → rejection cycle reported here.
What Happened?
DB Sync repeatedly rejects automatic duplicate-block-order repairs with reason: "db transact failed". Reject handling rolls back the repair, recreates the duplicate orders, then immediately generates another equivalent :fix transaction with a new UUID. Repeated rejection keeps the graph stuck and accumulates failed client_ops rows rather than terminating or surfacing a recoverable state.
This report distinguishes two findings:
- Observed live: repeated
tx-rejectederrors with changing failed transaction UUIDs while the WebSocket remains open and local/remote transaction positions remain equal. A captured queue contained 66,961 failed:fixoperations and 178 pending:fixoperations; there were no other failed operation types in that capture. - Reproduced offline: the installed client's actual rollback/rebase/repair and transaction persistence code regenerates equivalent repairs when rejection is injected. This reproduces the client feedback loop, not the underlying server exception.
The exact captured repair changes the order of two siblings from duplicate b5w values to b5wV and b5x. It is valid against the captured local graph and schema using the installed ldb/transact! with validation active. Reverse/apply each changes four datoms; repeating the repair changes zero datoms.
Reproduce the Bug
Scope: a deterministic client reject-path reproduction, not a demonstrated UI-only trigger for the original server rejection. Use an isolated connection and queue, never a production graph.
- Create an isolated DataScript connection with
:block/uuidas unique identity and:block/parentas a reference. Create a parent and three sibling blocks. The first two have:block/order "b5w"; the following sibling has:block/order "b5xV". Use ascending UUIDs for the first two siblings. - Register the connection and a real SQLite
client_opsstore with the worker's normal local-transaction listener/persistence path. Applylogseq.db-sync.order/fix-duplicate-orders!to the initial transaction report with:outliner-op :fixand undo generation disabled. This creates a pending repair with a forward and reverse payload. - The generated repair sets the first two siblings to
b5wVandb5x. Optionally add a subsequent local edit to exercise rebase/preservation of unrelated pending changes. - Inject rejection of the pending repair. The offline experiment directly called the installed
frontend.worker.sync.apply-txs/rollback-and-mark-failed-txs!with the pending repair's UUID—the function invoked byhandle-tx-reject!for a matching in-flight:failed-tx-id. - Inspect both the DataScript state and SQLite queue. The original repair is failed, but a new pending
:fixtransaction repairs the same duplicate orders with a different UUID. - Reject that replacement transaction. A second equivalent replacement is generated and another failed row is retained. The pending repair count remains stable while failed rows increase.
Synthetic structural fixture (fictional IDs and UUIDs):
;; Minimal DataScript shape for the isolated order/reject experiment;
;; not an importable full Logseq graph or an input to a production graph.
(def schema
{:block/uuid {:db/unique :db.unique/identity}
:block/parent {:db/valueType :db.type/ref}})
(def seed
[{:db/id 1 :block/uuid #uuid "00000000-0000-4000-8000-000000000001"}
{:db/id 2 :block/uuid #uuid "00000000-0000-4000-8000-000000000002"
:block/parent 1 :block/order "b5w" :block/title "example"}
{:db/id 3 :block/uuid #uuid "00000000-0000-4000-8000-000000000003"
:block/parent 1 :block/order "b5w"}
{:db/id 4 :block/uuid #uuid "00000000-0000-4000-8000-000000000004"
:block/parent 1 :block/order "b5xV"}])
;; Expected forward repair (two cardinality-one replacements;
;; the transaction report contains four datoms, including retractions):
[[:db/add 2 :block/order "b5wV"]
[:db/add 3 :block/order "b5x"]]
;; Reverse payload restores the collision:
[[:db/add 2 :block/order "b5w"]
[:db/add 3 :block/order "b5w"]]
Recorded isolated replay against a copy of the captured real queue:
| Stage | Pending operations | Failed operations | Total rows |
|---|---|---|---|
| Before injected rejection | 178 | 66,961 | 67,410 |
| After first injected rejection | 178 | 66,962 | 67,411 |
| After second injected rejection | 178 | 66,963 | 67,412 |
The graph remains locally repaired after each completed cycle; rollback temporarily restores the collision, which is what generates the replacement repair. The original server rejection cause is not established by this experiment.
Expected Behavior
Rejecting an automatic repair should not generate an unbounded sequence of equivalent repairs with fresh UUIDs and growing failed-operation storage. The client should preserve pending user edits and surface an actionable failure/reconciliation state rather than remain in this feedback loop.
Merely skipping order repair is not sufficient: the isolated experiment then leaves duplicate orders, and later repair processing regenerates the repair.
Screenshots
Not applicable: this report concerns worker transaction handling and SQLite queue state. Sanitized structural input and recorded results are included above.
Files
No real graph, SQLite database, full datom capture, or unreviewed console dump is attached because these contain private data. The structural fixture and aggregate replay results above contain no original graph names, block UUIDs, entity IDs, note content, local paths, account identifiers, or credentials.
Browser, Desktop or Mobile Platform Information
- Platform: macOS desktop, Apple Silicon (arm64), Darwin 25.6.0.
- Logseq: 2.0.1, reported revision
5a23230a56-dirty. - Graph: database graph, using DB Sync, not a Markdown/file graph.
- The installed build reports
-dirty; reproduction is against installed code. Behavior on the latest upstream build has not been established. - Relevant browser-worker and Node-worker source-map sources were compared and matched for rollback/rebase/repair and the DataScript/database functions exercised by the offline replay.
Additional Context
Relevant client path
Revision-linked source locations (installed source-map line numbers below may differ from the public commit because the installed build reports -dirty):
frontend.worker.sync.handle-message/handle-tx-reject!, installed lines 167–228: filters rejection IDs against in-flight IDs and dispatches rollback.frontend.worker.sync.apply-txs/rollback-and-mark-failed-txs!, installed lines 752–802: reverses the rejected transaction and subsequent pending transactions, rebases non-rejected pending transactions, then callsrepair-applied-txs!.repair-applied-txs!/sync-fix-tx-metain the same file, installed lines 1580–1589: repair metadata contains:outliner-op :fixand a fresh(random-uuid).logseq.db-sync.order/fix-duplicate-orders!, installed lines 5–46: detects sibling order collisions and transacts replacement fractional order keys.
Local validity and persistence checks
- The exact captured forward/reverse repair was exercised against 191,529 captured datoms and the captured schema through the installed
ldb/transact!, with local validation active. Repeating it and all 178 captured pending repairs produced no additional datom changes on the already-repaired local state. - A separate synthetic replay with a later user edit preserved that edit locally and pending under its original transaction UUID across two rejected repairs and a fresh Node process reopening the SQLite queue. The repair failure mechanism remained after reopening.
- Rejection was injected in offline experiments. No claim is made that missing remote blocks, a particular server schema error, or the cleanup plugin caused the actual rejection.
Reversible live containment test
Using the native worker APIs, transaction uploads were paused for approximately 15 seconds and then restored:
- After one already-in-flight rejection, the last rejection UUID/timestamp stayed unchanged at the 2-, 8-, and 15-second observations.
- 190 pending local operations remained, the WebSocket stayed open, and queue file size remained unchanged during those observations.
thread-api/db-sync-resume-uploadrestored the gate but did not immediately flush in this test. Callingthread-api/db-sync-startfor the already-active client enqueued a flush and fresh rejections resumed.- The native control used was
thread-api/db-sync-stop-uploadwith the local repository argument. It is containment, not a sync repair; it pauses outgoing database transaction uploads and resets in a fresh worker process. Remote-edit delivery during the pause was not tested. - No live graph/queue/binary edits or app restarts were performed. Uploads were restored after the test.
Missing server diagnostics
The installed handle-tx-reject! retains the reason and transaction metadata but does not retain :error-detail or :retryable in its recorded rejection data. The current public server handler emits those fields for transaction exceptions. The deployed server revision and actual exception are unknown; retaining sanitized error detail would help determine why this locally valid repair is rejected.
Are you willing to submit a PR? If you know how to fix the bug.
- I'm willing to submit a PR (Thank you!)
- 主要语言
- 没有语言数据
- 星标
- 29
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
logseq/db-test 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
-
Potential Dataloss: Deleting an entry from the property page's node table has no confirmation dialog可能已有人在做 @tiensonqin 于 59 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
-
Disabling Flashcards in Settings does not disable Flashcard shortcuts or tags可能已有人在做 @tiensonqin 于 60 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
相似的 Issue
-
`TezosTzktDatasource.iter_transactions` drops the address filter and the level range可能已有人在做 @Xnadir 今天认领。 未关闭bug
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
Becksteinlab/imdclient#161 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 62/100
zapcooking/frontend#1018 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 2 天内回复
-
geodata good first issue
难度 2/5 1-3 小时 新手友好度 62/100