[ARVADOS] created: 1.3.0-2590-g0098b7a71

Git user git at public.arvados.org
Wed May 20 03:38:02 UTC 2020


        at  0098b7a718d7c23af9621cfccb1ee7a92512bf87 (commit)


commit 0098b7a718d7c23af9621cfccb1ee7a92512bf87
Author: Tom Clegg <tom at tomclegg.ca>
Date:   Tue May 19 23:35:33 2020 -0400

    16319: Use high precision clock for file timestamps.
    
    Fixes occasional test failures caused by artificially old file
    timestamps.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at tomclegg.ca>

diff --git a/services/keepstore/unix_volume.go b/services/keepstore/unix_volume.go
index ceccd11c9..9dbb0c3f3 100644
--- a/services/keepstore/unix_volume.go
+++ b/services/keepstore/unix_volume.go
@@ -298,6 +298,17 @@ func (v *UnixVolume) WriteBlock(ctx context.Context, loc string, rdr io.Reader)
 		v.os.Remove(tmpfile.Name())
 		return err
 	}
+	// ext4 uses a low-precision clock and effectively backdates
+	// files by up to 10 ms, sometimes across a 1-second boundary,
+	// which produces confusing results in logs and tests.  We
+	// avoid this by setting the output file's timestamps
+	// explicitly, using a higher resolution clock.
+	ts := syscall.NsecToTimespec(time.Now().UnixNano())
+	if err = syscall.UtimesNano(tmpfile.Name(), []syscall.Timespec{ts, ts}); err != nil {
+		err = fmt.Errorf("error setting timestamps on %s: %s", tmpfile.Name(), err)
+		v.os.Remove(tmpfile.Name())
+		return err
+	}
 	if err := v.os.Rename(tmpfile.Name(), bpath); err != nil {
 		err = fmt.Errorf("error renaming %s to %s: %s", tmpfile.Name(), bpath, err)
 		v.os.Remove(tmpfile.Name())

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list