You are not logged in.

#1 2019-04-11 21:35:17

blochl
Member
Registered: 2018-08-31
Posts: 77

[Solved] 'repo-add' on a remote mount - is the db update atomic?

Hi,

I update my custom remote repository by mounting it via SSHFS, copying the new packages there, cd there, and:
`repo-add repo.db.tar.gz package_1 package_2 ...`

It works fine, but other users do the same, to the same repository, possibly simultaneously.

I know that `repo-add` creates a lockfile, supposedly atomically, with:
`set -o noclobber; echo "$$" > "$LOCKFILE"`

So on a local storage that poses no problem. But how about a remote mount? Is there a theoretical danger of a corrupt database?

P.S. I mount the SSHFS with `-o cache=no`.

Last edited by blochl (2019-04-13 15:42:10)

Offline

#2 2019-04-11 22:40:17

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,385
Website

Re: [Solved] 'repo-add' on a remote mount - is the db update atomic?

LOCKFILE is the repo db file path+name with .lck appended.   So this should be safe.

Offline

#3 2019-04-11 22:52:30

blochl
Member
Registered: 2018-08-31
Posts: 77

Re: [Solved] 'repo-add' on a remote mount - is the db update atomic?

Allan wrote:

LOCKFILE is the repo db file path+name with .lck appended.   So this should be safe.

But on a remote mount, there is no guarantee that while one user started to write the .lck, the other user will see it, if the process is started simultaneously. Or is there?
In other words, is there a guarantee for this operation to be atomic?

Offline

#4 2019-04-11 23:30:15

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,385
Website

Re: [Solved] 'repo-add' on a remote mount - is the db update atomic?

If you can't rely on a file being seen on the filesystem, then no it is not.

Offline

#5 2019-04-13 15:41:50

blochl
Member
Registered: 2018-08-31
Posts: 77

Re: [Solved] 'repo-add' on a remote mount - is the db update atomic?

Allan wrote:

If you can't rely on a file being seen on the filesystem, then no it is not.

Well, I guess so. Moved the repo-add run to the server side now. Thanks.

Offline

Board footer

Powered by FluxBB