rocksdb/include/rocksdb
Anand Ananthabhotla a27fce408e Auto recovery from out of space errors (#4164)
Summary:
This commit implements automatic recovery from a Status::NoSpace() error
during background operations such as write callback, flush and
compaction. The broad design is as follows -
1. Compaction errors are treated as soft errors and don't put the
database in read-only mode. A compaction is delayed until enough free
disk space is available to accomodate the compaction outputs, which is
estimated based on the input size. This means that users can continue to
write, and we rely on the WriteController to delay or stop writes if the
compaction debt becomes too high due to persistent low disk space
condition
2. Errors during write callback and flush are treated as hard errors,
i.e the database is put in read-only mode and goes back to read-write
only fater certain recovery actions are taken.
3. Both types of recovery rely on the SstFileManagerImpl to poll for
sufficient disk space. We assume that there is a 1-1 mapping between an
SFM and the underlying OS storage container. For cases where multiple
DBs are hosted on a single storage container, the user is expected to
allocate a single SFM instance and use the same one for all the DBs. If
no SFM is specified by the user, DBImpl::Open() will allocate one, but
this will be one per DB and each DB will recover independently. The
recovery implemented by SFM is as follows -
  a) On the first occurance of an out of space error during compaction,
subsequent
  compactions will be delayed until the disk free space check indicates
  enough available space. The required space is computed as the sum of
  input sizes.
  b) The free space check requirement will be removed once the amount of
  free space is greater than the size reserved by in progress
  compactions when the first error occured
  c) If the out of space error is a hard error, a background thread in
  SFM will poll for sufficient headroom before triggering the recovery
  of the database and putting it in write-only mode. The headroom is
  calculated as the sum of the write_buffer_size of all the DB instances
  associated with the SFM
4. EventListener callbacks will be called at the start and completion of
automatic recovery. Users can disable the auto recov ery in the start
callback, and later initiate it manually by calling DB::Resume()

Todo:
1. More extensive testing
2. Add disk full condition to db_stress (follow-on PR)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4164

Differential Revision: D9846378

Pulled By: anand1976

fbshipit-source-id: 80ea875dbd7f00205e19c82215ff6e37da10da4a
2018-09-15 13:43:04 -07:00
..
utilities Skip concurrency control during recovery of pessimistic txn (#4346) 2018-09-10 16:57:53 -07:00
advanced_options.h Allow ttl to be changed dynamically (#4133) 2018-07-16 14:27:53 -07:00
c.h Memory usage stats in C API (#4340) 2018-09-13 14:27:31 -07:00
cache.h LRUCache midpoint insertion 2018-05-24 15:57:33 -07:00
cleanable.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
compaction_filter.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
compaction_job_stats.h Fix some typos in comments and docs. 2018-03-08 10:27:25 -08:00
comparator.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
convenience.h Delete files in multiple ranges at once 2018-01-30 13:56:39 -08:00
db_bench_tool.h Change RocksDB License 2017-07-15 16:11:23 -07:00
db_dump_tool.h Fix some typos in comments and docs. 2018-03-08 10:27:25 -08:00
db.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
env_encryption.h Fix some typos in comments and docs. 2018-03-08 10:27:25 -08:00
env.h Auto recovery from out of space errors (#4164) 2018-09-15 13:43:04 -07:00
experimental.h Change RocksDB License 2017-07-15 16:11:23 -07:00
filter_policy.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
flush_block_policy.h Change RocksDB License 2017-07-15 16:11:23 -07:00
iostats_context.h Change RocksDB License 2017-07-15 16:11:23 -07:00
iterator.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
ldb_tool.h Change RocksDB License 2017-07-15 16:11:23 -07:00
listener.h Auto recovery from out of space errors (#4164) 2018-09-15 13:43:04 -07:00
memtablerep.h Adding a method for memtable class for memtable getting flushed. (#4304) 2018-08-23 17:14:25 -07:00
merge_operator.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
metadata.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
options.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
perf_context.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
perf_level.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
persistent_cache.h Change RocksDB License 2017-07-15 16:11:23 -07:00
rate_limiter.h Comment out unused variables 2018-03-05 13:13:41 -08:00
slice_transform.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
slice.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
snapshot.h Change RocksDB License 2017-07-15 16:11:23 -07:00
sst_dump_tool.h Change RocksDB License 2017-07-15 16:11:23 -07:00
sst_file_manager.h Expose GetTotalTrashSize in SstFileManager interface (#4206) 2018-08-04 17:57:48 -07:00
sst_file_writer.h Support range deletion tombstones in IngestExternalFile SSTs (#3778) 2018-07-13 22:43:09 -07:00
statistics.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
status.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
table_properties.h Index value delta encoding (#3983) 2018-08-09 16:58:40 -07:00
table.h Inline doc for format_version 4 (#4350) 2018-09-07 07:57:30 -07:00
thread_status.h fix ThreadStatus for bottom-pri compaction threads 2017-12-14 14:57:49 -08:00
threadpool.h Change RocksDB License 2017-07-15 16:11:23 -07:00
trace_reader_writer.h Trace and Replay for RocksDB (#3837) 2018-08-01 00:27:08 -07:00
transaction_log.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
types.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
universal_compaction.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
version.h Increase version number to 5.16 (#4176) 2018-07-24 13:43:33 -07:00
wal_filter.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
write_batch_base.h Fix some typos in comments and docs. 2018-03-08 10:27:25 -08:00
write_batch.h Support pragma once in all header files and cleanup some warnings (#4339) 2018-09-05 18:13:31 -07:00
write_buffer_manager.h Change RocksDB License 2017-07-15 16:11:23 -07:00