Skip to content

Commit

Permalink
rwlock: flush and fsync
Browse files Browse the repository at this point in the history
It is important that we ensure that rwlocked contents are flushed to
disk, because otherwise other rwlock readers might get outdated state.

Kudos @shcheklein for catching this one.
  • Loading branch information
efiop committed Jan 6, 2020
1 parent e2efb7b commit c190643
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dvc/rwlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def _edit_rwlock(lock_dir):
yield lock
with open(path, "w+") as fobj:
json.dump(lock, fobj)
# NOTE: flush and fsync to ensure that rwlock contents are saved
fobj.flush()
os.fsync(fobj.fileno())


def _infos_to_str(infos):
Expand Down

0 comments on commit c190643

Please sign in to comment.