Skip to content

DB sync: a member's first block is rejected (tx-rejected, "Nothing found for entity id") because their user page is created only locally during graph download #14096

Closed

Description

@pdbintheusa

Search first

  • I searched and no similar issues were found

What Happened?

A second account is invited to a DB graph as a member and downloads it. From then on the server rejects every new block that account creates:

{:code :tx-rejected :reason "db transact failed"
:error-detail "... Nothing found for entity id [:block/uuid #uuid "<the member's user uuid>"]"
:missing-block-uuids [#uuid "<the member's user uuid>"]}
The client rolls the block back. Editing the text of an existing, non-empty block still syncs, because that sets no :logseq.property/created-by-ref. The local and remote checksums stay different even when local-tx equals remote-tx and nothing is pending.

The missing uuid is the member's own user page (:logseq.property.user/name, the sub of their id token). It exists in the member's local DB but never reaches the server.

It happens on the desktop app and on the CLI, and with encrypted and unencrypted graphs. Removing the local copy and downloading again doesn't help: the user page appears locally a few seconds after every download, before any edit.

Reproduce the Bug

  1. Account A creates a DB graph with sync enabled (E2EE on or off).
  2. A invites account B as a member.
  3. B downloads the graph (desktop app, or logseq sync download --graph ).
  4. B creates a new block anywhere, for example logseq upsert block --graph --target-page "" --content "test".
  5. Result: sync status shows last-error tx-rejected with the missing uuid above, and the block is rolled back. A can create blocks normally.

NOTE: This occurs both on the desktop app as well as with Logseq CLI

Expected Behavior

B's first block is accepted, with B's user page uploaded alongside it.

Screenshots

No response

Desktop or Mobile Platform Information

Logseq CLI 2.0.2 (revision 533ac43), Linux, Node
Windows Desktop app: 2.0.2
Web app at app.logseq.com
Sync: self-hosted db-sync server (although a fix on the CLI code resolved the issue, noted below)
Graphs: DB graphs, one E2EE and one not

Additional Context

Cause (from reading master at d58ba11)
add-created-by-ref-hook in src/main/frontend/worker/pipeline.cljs has two problems that combine:

The download skip checks the wrong flag. The hook returns early when rtc-tx-or-download-graph? matches, which is (some-fn :rtc-op? :rtc-tx? :rtc-download-graph? :transact-remote?). But the db-sync download transacts with {:sync-download-graph? true} (worker/sync/download.cljs, db_worker_node.cljs:472). Elsewhere both flags are treated as downloads: db_listener.cljs:61-62 checks both, and persistable-local-tx-meta? in sync/apply_txs.cljs excludes :sync-download-graph?. So the hook runs on download transactions, and those transactions are then (correctly) never uploaded.
The user page is added to any transaction while it's missing, even one that references it nowhere. The hook ends with
(cond->> add-created-by-tx-data
(nil? created-by-ent) (cons created-by-block))
so created-by-block (the user page) is added whenever it doesn't exist locally, even when add-created-by-tx-data is empty. Any transaction that isn't uploaded will create it: download, or other :persist-op? false transactions.
Together, B's user page is created inside a non-uploaded download transaction. Later local transactions find it with d/entity and only add [:db/add e :logseq.property/created-by-ref ], never the page itself, so the server has nothing for that uuid and rejects them.

Suggested fix
The patch is attached (logseq-created-by-fix.patch, against d58ba11):

  • (let [p (some-fn :rtc-op? :rtc-tx? :rtc-download-graph? :transact-remote?)]
  • (let [p (some-fn :rtc-op? :rtc-tx? :rtc-download-graph? :sync-download-graph? :transact-remote?)]
  •    ;; Only create the user page when this tx actually references it.
       (cond->> add-created-by-tx-data
    
  •      (nil? created-by-ent) (cons created-by-block))))))
    
  •      (and (nil? created-by-ent) (seq add-created-by-tx-data))
    
  •      (cons created-by-block))))))
    

Open PR #13644 changes the skip condition in the same function (for redo), so the two may need reconciling.

rtc-tx-or-download-graph? is also used by other hooks in pipeline.cljs (template insertion, revert-disallowed-changes and others). If adding the flag there is too broad, the narrower option is to check :sync-download-graph? only inside add-created-by-ref-hook.

Verified
I applied the same two changes to the compiled db-worker-node.js of CLI 2.0.2 (revision 533ac43, the minified Rg.l($ea,sL,Tza,F([ps],0)) and the hook's return expression):

After removing and re-downloading the graph, no user page was created.
B's first new block was accepted, with the user page uploaded in the same transaction, and the checksums matched.
After reverting to the stock CLI, B could still create blocks, because the page was now on the server.
Reproduced on one encrypted and one unencrypted graph.

Workaround for affected users (until fixed): there's no supported one. A desktop edit by B no longer works, because the desktop app also creates the page during download.

Are you willing to submit a PR? If you know how to fix the bug.

  • I'm willing to submit a PR (Thank you!)

Activity

  1. added a commit that references this issue on Nov 23, 2026
    f6ce0e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions