facebook / facebook/rocksdb

FileSystem API: No way to atomically open for read and determine file existence

Open
#9,021 0 comments 0 reactions 0 assignees View on GitHub
enhancement up-for-grabs
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

It seems like it would be a common operation to want to open a file for reading if it exists, or if not successful, find out whether that was because the file does not (did not) exist. I would expect Status::NotFound to serve this purpose, but in PosixFileSystem I find that NewSequentialFile returns IOError if the file doesn't exist. Without this functionality, there is an inherent TOCTOU race on checking file existence and opening for reading. Do we expect there are file systems that won't be able to distinguish why a file can't be opened?

https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.