Skip to content

database is locked error when hiedb is run concurrently #63

@9999years

Description

@9999years

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.

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