Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a grace period to obtain the lock to avoid "Error: lock /data/ipfs/repo.lock: someone else has the lock" #10482

Open
3 tasks done
meermanr opened this issue Aug 18, 2024 · 0 comments
Labels
kind/enhancement A net-new feature or improvement to an existing feature

Comments

@meermanr
Copy link

Checklist

  • My issue is specific & actionable.
  • I am not suggesting a protocol enhancement.
  • I have searched on the issue tracker for my issue.

Description

I want to use IPFS to distribute an OS update image to 100s of hosts in my compute estate, but I've been seeing a lot of the following error if I run, say, ipfs pin add ... while the ipfs daemon is still initialising:

Error: lock /data/ipfs/repo.lock: someone else has the lock

I was about to add some logic to backoff and retry in my Ansible playbook when it occurred to me that the ipfs CLI itself could do implement this and become easier to script this sort of usage.

I propose that instead of failing immediately the ipfs CLI should display a warning and then wait for the lock to become available. The warning could be displayed periodically, perhaps every 10s. I imagine my use case might look something like this:

# ipfs pin add /ipfs/bafyb4igq3a5ufgoaofhvmaxhhy7w4afpg6wpy42h646rro4fzds7d4sapm
WARNING: lock /data/ipfs/repo.lock: someone else has the lock. Retrying...
WARNING: lock /data/ipfs/repo.lock: someone else has the lock. Retrying...
WARNING: lock /data/ipfs/repo.lock: someone else has the lock. Retrying...
NOTICE  lock /data/ipfs/repo.lock: obtained
pinned bafyb4iftumpemeammdgxbxxkxoocftvgyzs3ljcdtvjipqrmltexpz7sbu recursively

In this session the lock was not available for somewhere between 30-40s. I would expect the warnings to be written to STDERR so as not to interfere with tools which may rely on the output of the CLI's STDOUT.

@meermanr meermanr added the kind/enhancement A net-new feature or improvement to an existing feature label Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant