You should not need to call that function twice.
It goes through all the notes and can take long; it should be a one time thing.
You should not need to update org-id-locations-file for each node unless you are using your custom ID (not generated by one of the org-id functions).
I use something like this below because I prefer my Org-ID to be in my own timestamp format. You should not have to use it if you use the normal Org-ID and Org-roam functions.
(defun my/org-id-update-location-at-org-roam-db-insert-file ()
"Update `org-id-locations-file' and hash table.
It's meant to be used with `advice-add' :after
`org-roam-db-insert-file'. We can assume that this function is
run wihtin a buffer visiting a file being inserted, as
insert-file is run within `org-roam-with-file' macro."
(when-let ((id (org-entry-get 1 "id")))
(org-id-add-location id (buffer-file-name))))
(advice-add #'org-roam-db-insert-file :after
#'my/org-id-update-location-at-org-roam-db-insert-file)
A-ha, thanks. I am using the standard org-id functions I believe, so perhaps I did something which cleared org-id-locations-file somehow. I haven’t had to run the update again, as of yet.
The need for calling db-sync suggests to me that your hooks are not correctly set. You might like to check variable after-save-hook. It is probably locally set, so check this in your org-roam file. You should see some org-roam related function to take care of db file/node update. If you don’t see it, check if you call org-roam-setup in your init.
I suspect org-id part of the issue might be different (org-roam-setup itself does not do anything for org-id-locations-file). You might like to check if adding a new node also correctly updates the org-id-locations-file… You should not have to call function org-id-add-location
For reference for any other spacemacs users seeing this - the call to (org-roam-setup) is now in the org layer, so you don’t need to add it to your own user-config.