Go to file
anand76 afa2420c2b Introduce a new storage specific Env API (#5761)
Summary:
The current Env API encompasses both storage/file operations, as well as OS related operations. Most of the APIs return a Status, which does not have enough metadata about an error, such as whether its retry-able or not, scope (i.e fault domain) of the error etc., that may be required in order to properly handle a storage error. The file APIs also do not provide enough control over the IO SLA, such as timeout, prioritization, hinting about placement and redundancy etc.

This PR separates out the file/storage APIs from Env into a new FileSystem class. The APIs are updated to return an IOStatus with metadata about the error, as well as to take an IOOptions structure as input in order to allow more control over the IO.

The user can set both ```options.env``` and ```options.file_system``` to specify that RocksDB should use the former for OS related operations and the latter for storage operations. Internally, a ```CompositeEnvWrapper``` has been introduced that inherits from ```Env``` and redirects individual methods to either an ```Env``` implementation or the ```FileSystem``` as appropriate. When options are sanitized during ```DB::Open```, ```options.env``` is replaced with a newly allocated ```CompositeEnvWrapper``` instance if both env and file_system have been specified. This way, the rest of the RocksDB code can continue to function as before.

This PR also ports PosixEnv to the new API by splitting it into two - PosixEnv and PosixFileSystem. PosixEnv is defined as a sub-class of CompositeEnvWrapper, and threading/time functions are overridden with Posix specific implementations in order to avoid an extra level of indirection.

The ```CompositeEnvWrapper``` translates ```IOStatus``` return code to ```Status```, and sets the severity to ```kSoftError``` if the io_status is retryable. The error handling code in RocksDB can then recover the DB automatically.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5761

Differential Revision: D18868376

Pulled By: anand1976

fbshipit-source-id: 39efe18a162ea746fabac6360ff529baba48486f
2019-12-13 14:48:41 -08:00
buckifier PosixRandomAccessFile::MultiRead() to use I/O uring if supported (#5881) 2019-12-07 20:55:52 -08:00
build_tools Improve instructions to install formatter (#6162) 2019-12-12 14:04:01 -08:00
cache Remove key length assertion LRUHandle::CalcTotalCharge (#6115) 2019-12-02 15:00:07 -08:00
cmake cmake: do not build tests for Release build and cleanups (#5916) 2019-12-13 12:48:06 -08:00
coverage
db Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
db_stress_tool Add useful idioms to Random API (OneInOpt, PercentTrue) (#6154) 2019-12-13 14:30:14 -08:00
docs
env Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
examples Add example to show the effect of Get in snapshot isolation (#6059) 2019-12-11 09:56:42 -08:00
file Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
hdfs
include/rocksdb Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
java Correct java docs of RocksDB options (#6123) 2019-12-12 18:10:03 -08:00
logging Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
memory Charge block cache for cache internal usage (#5797) 2019-09-16 15:26:21 -07:00
memtable Misc hashing updates / upgrades (#5909) 2019-10-24 17:16:46 -07:00
monitoring Apply formatter to recent 200+ commits. (#5830) 2019-09-20 12:04:26 -07:00
options Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
port Work around weird unused errors with Mingw (#6075) 2019-11-26 21:42:29 -08:00
table Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
test_util Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
third-party Apply formatter to some recent commits (#6138) 2019-12-09 15:49:49 -08:00
tools Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
trace_replay Misc hashing updates / upgrades (#5909) 2019-10-24 17:16:46 -07:00
util Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
utilities Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
.clang-format
.gitignore Make buckifier python3 compatible (#5922) 2019-10-23 13:52:27 -07:00
.lgtm.yml
.travis.yml cmake: do not build tests for Release build and cleanups (#5916) 2019-12-13 12:48:06 -08:00
.watchmanconfig
AUTHORS
CMakeLists.txt Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md
COPYING
DEFAULT_OPTIONS_HISTORY.md
DUMP_FORMAT.md
HISTORY.md Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
INSTALL.md
LANGUAGE-BINDINGS.md
LICENSE.Apache
LICENSE.leveldb
Makefile Add useful idioms to Random API (OneInOpt, PercentTrue) (#6154) 2019-12-13 14:30:14 -08:00
README.md Replaced some words (#5877) 2019-10-07 12:28:09 -07:00
ROCKSDB_LITE.md
TARGETS Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
USERS.md
Vagrantfile
WINDOWS_PORT.md
appveyor.yml Add Visual Studio 2015 to AppVeyor (#5446) 2019-12-10 20:02:31 -08:00
defs.bzl Add clarifying/instructive header to TARGETS and defs.bzl 2019-11-05 20:20:33 -08:00
issue_template.md
src.mk Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
thirdparty.inc

README.md

RocksDB: A Persistent Key-Value Store for Flash and RAM Storage

Linux/Mac Build Status Windows Build status PPC64le Build Status

RocksDB is developed and maintained by Facebook Database Engineering Team. It is built on earlier work on LevelDB by Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com)

This code is a library that forms the core building block for a fast key-value server, especially suited for storing data on flash drives. It has a Log-Structured-Merge-Database (LSM) design with flexible tradeoffs between Write-Amplification-Factor (WAF), Read-Amplification-Factor (RAF) and Space-Amplification-Factor (SAF). It has multi-threaded compactions, making it especially suitable for storing multiple terabytes of data in a single database.

Start with example usage here: https://github.com/facebook/rocksdb/tree/master/examples

See the github wiki for more explanation.

The public interface is in include/. Callers should not include or rely on the details of any other header files in this package. Those internal APIs may be changed without warning.

Design discussions are conducted in https://www.facebook.com/groups/rocksdb.dev/

License

RocksDB is dual-licensed under both the GPLv2 (found in the COPYING file in the root directory) and Apache 2.0 License (found in the LICENSE.Apache file in the root directory). You may select, at your option, one of the above-listed licenses.