When I run hiedb index .hiefiles concurrently, the second process errors because the first has already locked the database:
$ hiedb index .hiefiles >/dev/null 2>&1 &; hiedb index .hiefiles
hiedb: SQLite3 returned ErrorBusy while attempting to perform step: database is locked
Context
We're using ghciwatch for development in combination with static-ls for language intelligence. ghciwatch handles loading and compiling modules in ghci for rapid reloads, and static-ls leverages hiedb to provide language intelligence. (Our project is too big for haskell-language-server.)
We're using ghciwatch's lifecycle hooks to reindex the hiefiles on reloads:
ghciwatch \
--after-reload-shell "async:hiedb -D .hiedb index .hiefiles" \
--before-restart-shell "async:hiedb -D .hiedb index .hiefiles"
Because ghciwatch runs these commands asynchronously (so that it can keep reloading and responding to changes while the files are indexed), it's possible for multiple hiedb processes to run at once (especially on the first load when 7500+ modules are being indexed), which has been triggering this bug.
I have a few ideas for working around this in ghciwatch (only allowing one of each hook to run at once, killing old hook processes before launching new ones, etc.), but I think we should fix this in hiedb as well.
When I run
hiedb index .hiefilesconcurrently, the second process errors because the first has already locked the database:Context
We're using
ghciwatchfor development in combination withstatic-lsfor language intelligence.ghciwatchhandles loading and compiling modules inghcifor rapid reloads, andstatic-lsleverageshiedbto provide language intelligence. (Our project is too big forhaskell-language-server.)We're using
ghciwatch's lifecycle hooks to reindex the hiefiles on reloads:Because
ghciwatchruns these commands asynchronously (so that it can keep reloading and responding to changes while the files are indexed), it's possible for multiplehiedbprocesses to run at once (especially on the first load when 7500+ modules are being indexed), which has been triggering this bug.I have a few ideas for working around this in
ghciwatch(only allowing one of each hook to run at once, killing old hook processes before launching new ones, etc.), but I think we should fix this inhiedbas well.