DB Sync: rejected duplicate-order repairs regenerate indefinitely and accumulate failed transactions
まだ誰も着手していません。
評価
- 難易度
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Becksteinlab/imdclient#161 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 2 日以内に返信
-
geodata good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
dgunning/edgartools#2019 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 72/100
alltheplaces/alltheplaces#20745 ·
メンテナーはふだん 1 日以内に返信