Skip to content

DB graph: deleting a property removes every page/block that held it from the search index (never re-added) #1153

Closed
logseq/logseq
#13173

Description

@ozanozyegen

Version: Logseq 2.0.1 desktop (macOS), DB graph. Reproduced through the db-worker-node; the same worker code path runs for the UI.

Steps to reproduce

  1. In a DB graph create a page Test Page and add a user property foo (any type) with a value.
  2. Search for Test Page — it is found.
  3. Delete the property foo (property page → delete, or logseq remove property).
  4. Search for Test Page again.

Expected: the page is still found.
Actual: the page (and any block that held foo) no longer appears in search. Only Rebuild search index — or editing the page title — brings it back. Nothing in the UI indicates the index is stale.

In my graph a property migration that deleted one Text property silently dropped 40 of 94 #Book pages plus ~60 blocks from search; the rows were still in Datascript, only the FTS blocks rows were gone.

Cause

frontend.worker.search/get-blocks-from-datoms-impl (master 445929442b):

remove-eids (set/union ref-eids (referrer-eids db-before ref-eids) ...)
add-eids    (set/union ref-eids (referrer-eids db-after  ref-eids) ...)

Deleting the property retracts its :block/uuid/:block/name/:block/title datoms, so the property eid is in ref-eids. Its holders reference it via :block/refs, so (referrer-eids db-before ref-eids) puts every holder into remove-eids. In db-after the property entity no longer exists, so (referrer-eids db-after ref-eids) is empty, and the holders' own titles did not change — they never reach add-eids. db_listener then deletes them from blocks/blocks_fts and upserts nothing.

Renaming a property (entity still exists in db-after) and hard-deleting a referenced block (referrers get a title rewrite) are fine; only entity deletion with surviving referrers hits this.

Suggested fix

Also include the before referrers on the add side, so referrers that still exist get re-indexed:

add-eids (set/union ref-eids
                    (referrer-eids db-before ref-eids)
                    (referrer-eids db-after ref-eids)
                    ...)

Entities that no longer exist in db-after are dropped by entities-for/block->index, and sync-search-indice already moves those into the remove set via the set/difference. A test in src/test/frontend/worker/search_test.cljs mirroring the existing deleted-at test (delete a property entity, assert its former holders are in :blocks-to-add) would cover it.

Workaround

Run Rebuild search index after deleting any property.

Activity

  1. mszummer commented on Sep 5, 2026

    @mszummer

    Cannot reproduce the above. Deletion seems to work as I expected.
    Also MacOS, Logseq DB 2.0.1
    Deleting property, and searching for page still shows.

  2. transferred this issue fromlogseq/logseqon Sep 5, 2026
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