Org-roam-node-find not seeing existing nodes after doing db-clear-all followed by db-sync for additional org-roam directory

I have a second instance/directory of org-roam running, otherwise fine and working as expected, setup per 18.1 org-roam manual. If I do a org-roam-db-clear-all followed by a org-roam-db-sync I cannot get org-roam-node-find to see all the existing nodes again. This only happens with the secondary instance, from another directory. links work (follows) fine. org-roam-list-files and org-id-update-id-locations identifies correctly - existing nodes just don’t seem to show up when doing org-roam-node-find.

With the main instance, it works fine.

Can anyone help?

Weird problem; I can reproduce this.

I have observed that only the files that have been already visited (thus buffer exists) when you do db-sync are put into the nodes table of the db. I tried to debug this but don’t know exactly why this is the case.

As a solution, see below.

You can put the following in an org file in the second instance’s directory (so as to use the same .dir-locals.el values) and:

  1. Visit one of the Org files in the second instance’s directory
  2. db-clear-all
  3. db-sync
  4. C-c C-c to evalute the dolist below (if it’s easier for you, you can just evaluate the dolist without putting into Org source block)
#+begin_src elisp
  (dolist (f (org-roam-list-files))
    (with-current-buffer (find-file-noselect f)
      (restore-buffer-modified-p t)

EDIT: Sorry, just changing the code to be easier…
EDIT the EDIT: OK, the only the original works. Back to the original code.

Essentially, it visits every file in the org-roam directory, changes the “modified” status – status only, no actual change – and saves it to update the Org-roam db. It might take a while if you have many files, but it has done the job on my end.

Hope this helps.

Thanks nobiot - it provides a workaround.

Have now also realised that after the db-sync, the links that should have been added to the second instance is instead added/accessible to/from the first/main instance.

seems like unintended behaviour… will open an issue.

thanks for your help nobiot.