rocksdb/env
Andrew Kryczka a4fb1f8c04 Add crash-recovery correctness check to db_stress
Summary:
Previously, our `db_stress` tool held the expected state of the DB in-memory, so after crash-recovery, there was no way to verify data correctness. This PR adds an option, `--expected_values_file`, which specifies a file holding the expected values.

In black-box testing, the `db_stress` process can be killed arbitrarily, so updates to the `--expected_values_file` must be atomic. We achieve this by `mmap`ing the file and relying on `std::atomic<uint32_t>` for atomicity. Actually this doesn't provide a total guarantee on what we want as `std::atomic<uint32_t>` could, in theory, be translated into multiple stores surrounded by a mutex. We can verify our assumption by looking at `std::atomic::is_always_lock_free`.

For the `mmap`'d file, we didn't have an existing way to expose its contents as a raw memory buffer. This PR adds it in the `Env::NewMemoryMappedFileBuffer` function, and `MemoryMappedFileBuffer` class.

`db_crashtest.py` is updated to use an expected values file for black-box testing. On the first iteration (when the DB is created), an empty file is provided as `db_stress` will populate it when it runs. On subsequent iterations, that same filename is provided so `db_stress` can check the data is as expected on startup.
Closes https://github.com/facebook/rocksdb/pull/3629

Differential Revision: D7463144

Pulled By: ajkr

fbshipit-source-id: c8f3e82c93e045a90055e2468316be155633bd8b
2018-04-24 15:58:22 -07:00
..
env_basic_test.cc Move some files under util/ to separate dirs 2017-04-05 19:09:16 -07:00
env_chroot.cc Change RocksDB License 2017-07-15 16:11:23 -07:00
env_chroot.h Change RocksDB License 2017-07-15 16:11:23 -07:00
env_encryption.cc Fix some typos in comments and docs. 2018-03-08 10:27:25 -08:00
env_hdfs.cc Disallow compactions if there isn't enough free space 2018-03-06 16:27:54 -08:00
env_posix.cc Add crash-recovery correctness check to db_stress 2018-04-24 15:58:22 -07:00
env_test.cc Add crash-recovery correctness check to db_stress 2018-04-24 15:58:22 -07:00
env.cc Add crash-recovery correctness check to db_stress 2018-04-24 15:58:22 -07:00
io_posix.cc Add crash-recovery correctness check to db_stress 2018-04-24 15:58:22 -07:00
io_posix.h Add crash-recovery correctness check to db_stress 2018-04-24 15:58:22 -07:00
mock_env_test.cc Move some files under util/ to separate dirs 2017-04-05 19:09:16 -07:00
mock_env.cc comment unused parameters to turn on -Wunused-parameter flag 2018-04-12 17:59:16 -07:00
mock_env.h Change RocksDB License 2017-07-15 16:11:23 -07:00
posix_logger.h Disallow compactions if there isn't enough free space 2018-03-06 16:27:54 -08:00