DB Sync: server rejects valid local order repair; same-identity restoration fails with UUID uniqueness conflict

未关闭
#1,518 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
12/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
clojure, macos, sqlite

调研方向

The rejection path is in src/main/frontend/worker/sync/handle_message.cljs, specifically handle-tx-reject!, which drops :error-detail from recorded status. The server-side UUID uniqueness conflict and index state are not in this repository and need a maintainer replay against the deployed revision. Done would mean the raw server error is retained and the same-entity UUID conflict is reproduced or ruled out; this is not a newcomer task.

由索引模型根据 Issue 内容生成。

描述

Search first
  • Searched logseq/db-test, logseq/logseq, and the Logseq Forum for validation failures, sync rejections, and UUID uniqueness conflicts.

Related: #1515 covers client repair-loop amplification. Historical #711 and logseq/logseq#12473 discuss missing-identity validation failures during remote apply/rebase. Neither establishes the same-identity server conflict captured here; #12473 was closed without merging after a rebase redesign. No exact duplicate was identified in these searches.

What Happened?

A duplicate-order repair passes the installed client's local transaction validation but is rejected by the deployed DB Sync server. Attempting to restore the affected block's full identity/content is also rejected, with a UUID uniqueness conflict involving the same entity ID and UUID at different transaction ordinals.

This report concerns the observed server rejection and failed identity restoration, separately from the client rejection/regeneration loop in #1515. The original event/code path that created the affected state is not established.

Captured server response (sanitized excerpt):

:type "tx/reject"
:reason "db transact failed"
:error-detail contains:
  "DB write failed with invalid data"
  :entity-map {:block/order "b5wV", :db/id E, :block/properties ()}
  :errors [["invalid dispatch value"]]

The server's diagnostic describes an order-only entity, missing block identity/content. E is a symbolic replacement, not a real entity ID.

Reproduce the Bug

Scope: the following affected-state sequence was exercised. There is no demonstrated fresh-graph/UI recipe for creating the original server condition. A maintainer replay needs the affected server's pre-apply state. Use isolated copies/test infrastructure, not a production graph.

  1. Preserve a matched client graph and operation queue containing the automatic two-sibling order repair. Both targets have complete local block identities. Its normalized forward payload is four datoms:

    [A :block/order "b5w"  T false]
    [A :block/order "b5wV" T true]
    [B :block/order "b5w"  T false]
    [B :block/order "b5x"  T true]
    

    A, B, and T are symbolic placeholders. These are transaction-report datoms, not an import script.

  2. Replay the exact captured repair on an isolated copy through the installed thread-api/transact / ldb/transact! path with validation active. Observed: accepted locally; repeating the repair on the repaired state changes zero datoms.

  3. Submit that pending repair to the affected deployed server in a bounded attempt. Capture the raw rejection at client handler entry, before detail is discarded. Observed: the order-only validation error above. Uploads were paused before normal rejection processing to prevent another storm.

  4. In a separate bounded diagnostic attempt, submit the existing target's complete identity/content and structural attributes. Observed:

    Cannot add #datascript/Datom [E :block/uuid U T_incoming true]
    because of unique constraint:
    (#datascript/Datom [E :block/uuid U T_conflicting true])
    

    This is a sanitized excerpt: E and U are identical in both datoms; T_incoming and T_conflicting differ. Explicitly retracting and reasserting the UUID also failed. These diagnostic attempts are not a recommended recovery procedure.

  5. Create a new sibling with a fresh UUID, identical text, and the same parent/page using the native CLI. Observed: upload accepted before removing the old local block. The distinct pending operations were also accepted during recovery.

Expected Behavior

Valid edits should apply consistently to the server's entity/identity state. Reasserting an existing identity should not encounter this same-entity UUID conflict; if reconciliation is required, provide an actionable, content-preserving recovery path and retain the detailed server error.

Screenshots

Not a UI issue. Sanitized payload/error structure is included above.

Files

No private graph, SQLite queue, raw logs, or screenshots attached. All graph/account names, original UUIDs, entity IDs, transaction ordinals, note text, local paths, and credentials are omitted. Matched backups and raw diagnostic evidence were retained privately.

Browser, Desktop or Mobile Platform Information
  • macOS desktop, Apple Silicon arm64; Darwin 25.6.0.
  • Logseq 2.0.1, installed revision 5a23230a56-dirty; database graph using DB Sync.
  • Deployed server revision/schema and pre-apply index state are unavailable. Latest-upstream equivalence has not been established.
Additional Context
  • Two separate malformed local entities were cleaned with content/children preserved. They were not the repair targets; local validation became clean without resolving the server rejection.
  • After targeted recovery: local validation had zero errors; all three distinct pending operations and the fresh-UUID block were accepted; pending local/server/assets were zero, connection open, last error null. Original queue backups and failed repairs were retained rather than clearing user operations.
  • Recomputed local and remote checksums still differ. Queue drainage proves working operation processing, not full replica consistency.
  • The deployed response contained :error-detail, but the installed handle-tx-reject! does not retain it in recorded rejection status.
  • Hypothesis, not proven cause: inconsistent server entity/UUID index or snapshot state. Please inspect the target's pre-apply EAVT/AVET/UUID-unique state and replay the repair on the deployed revision to identify the first inconsistent transition. The observed errors alone do not identify that transition or prove a specific index defect.
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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

logseq/db-test 的其他 Issue

查看 logseq/db-test 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。