DB Sync: rejected duplicate-order repairs regenerate indefinitely and accumulate failed transactions
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 18/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- clojure, javascript, sqlite
- Lĩnh vực
- data-engineering, database
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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!)
- Ngôn ngữ chính
- Không có dữ liệu ngôn ngữ
- Star
- 29
- Fork
- 2
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của logseq/db-test
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Potential Dataloss: Deleting an entry from the property page's node table has no confirmation dialogCó thể đã có người làm @tiensonqin đã nhận 59 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Disabling Flashcards in Settings does not disable Flashcard shortcuts or tagsCó thể đã có người làm @tiensonqin đã nhận 60 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Tất cả issue của logseq/db-test
Issue tương tự
-
fix energy term "van_der_walls"Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Becksteinlab/imdclient#161 ·
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày
-
geodata good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
dgunning/edgartools#2019 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
alltheplaces/alltheplaces#20745 ·
Maintainer thường phản hồi trong vòng 1 ngày