X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8af162e0e5703f8b3a1dd60d5fd9a110ff009e24..0d1971f04c8f0674ff8d94bae5dbb7f6b94e7f5f:/services/keepstore/volume_unix.go diff --git a/services/keepstore/volume_unix.go b/services/keepstore/volume_unix.go index 4db2a53384..84877c0034 100644 --- a/services/keepstore/volume_unix.go +++ b/services/keepstore/volume_unix.go @@ -255,6 +255,14 @@ func (v *UnixVolume) Index(prefix string) (output string) { } func (v *UnixVolume) Delete(loc string) error { + // Touch() must be called before calling Write() on a block. Touch() + // also uses lockfile(). This avoids a race condition between Write() + // and Delete() because either (a) the file will be deleted and Touch() + // will signal to the caller that the file is not present (and needs to + // be re-written), or (b) Touch() will update the file's timestamp and + // Delete() will read the correct up-to-date timestamp and choose not to + // delete the file. + p := v.blockPath(loc) f, err := os.OpenFile(p, os.O_RDWR|os.O_APPEND, 0644) if err != nil {