From c1906436c2b63b69508f739313620d4806e51728 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Mon, 6 Jan 2020 22:37:21 +0200 Subject: [PATCH] rwlock: flush and fsync 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. --- dvc/rwlock.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dvc/rwlock.py b/dvc/rwlock.py index bad2df9495..d0665483c3 100644 --- a/dvc/rwlock.py +++ b/dvc/rwlock.py @@ -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):