]> git.arvados.org - arvados.git/commit
20318: Avoid error when cache file is deleted while being written.
authorTom Clegg <tom@curii.com>
Fri, 12 Jan 2024 16:06:19 +0000 (11:06 -0500)
committerTom Clegg <tom@curii.com>
Fri, 12 Jan 2024 16:06:19 +0000 (11:06 -0500)
commitf6e6f83268a4665a050d10b4a790906598dc1018
tree76bf60f118ef04288c338ac2985d6ceaa425c5ae
parentcce2c381181ff560bc134845eaea91939e1f8888
20318: Avoid error when cache file is deleted while being written.

The previous code had one goroutine writing the cache file, and
another goroutine(s) waiting for it to finish, then opening the file
for reading. If the cache file was deleted before being opened for
reading, ReadAt would return an error.

The new code shares the writer's filehandle with all of the goroutines
that are waiting for it to finish writing. This ensures ReadAt can
always read from the newly written file even if it is deleted
mid-write.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>
sdk/go/arvados/keep_cache.go