#944 RFE: make volume moves closer to atomic
Opened 5 years ago by mikem. Modified 5 years ago

Right now, when Koji moves a build to a new volume, it takes the following steps:

  1. copy the build to the new location
  2. update the db (though this is in a transaction, so not committed til the end)
  3. delete the old content
  4. place a symlink, if appropriate

There are a couple issues with this.

Between the start of step 3 and the end of step 4, another client inspecting the build will still see the old volume and an incomplete or missing build dir.

This is likely aggravated by the fact that volume moves trigger repo regens. So, if you are moving a lot of related builds to a new volume, you may be ensuring that createrepo tasks are inspecting those builds during your overall move.

We should be able to make this better. Perhaps not atomic, but at least reduce the problem window and mitigate the fallout.


Ideas for addressing this:

  1. Instead of delete+symlink, we could rename+symlink+delete. That is, move the build dir to a temporary name (to get out out of the way), create the symlink, and then delete the old renamed dir. This still leaves a window between rename and symlink, but it is much smaller (and never involves a partially deleted build dir)
  2. Commit the db change after the copy. Well behaving clients will see the new volume before we touch the original location. However, even a well behaving client could have slightly old build data, and some clients are not volume aware.
  3. both 1 and 2

I am open to other ideas

Metadata Update from @mikem:
- Issue tagged with: discussion

5 years ago

Also, volume moves might not need to trigger repo regens, or at least, not promptly. It might be reasonable to rely on symlinks.

More of an "out there" idea: if every build dir was a symlink, we might be able to change them atomically.

https://unix.stackexchange.com/questions/5093/how-does-one-atomically-change-a-symlink-to-a-directory-in-busybox/6786

(I've no idea how well this will work or if it would work on nfs)

At any rate, this would be a pretty major change.

Login to comment on this ticket.

Metadata