Skip to content

Commit 1022df7

Browse files
riversand963tabokie
authored andcommitted
Stop tracking syncing live WAL for performance (facebook#10330)
Summary: With facebook#10087, applications calling `SyncWAL()` or writing with `WriteOptions::sync=true` can suffer from performance regression. This PR reverts to original behavior of tracking the syncing of closed WALs. After we revert back to old behavior, recovery, whether kPointInTime or kAbsoluteConsistency, may fail to detect corruption in synced WALs if the corruption is in the live WAL. Pull Request resolved: facebook#10330 Test Plan: make check Before facebook#10087 ```bash fillsync : 750.269 micros/op 1332 ops/sec 75.027 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync : 776.492 micros/op 1287 ops/sec 77.649 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync [AVG 2 runs] : 1310 (± 44) ops/sec; 0.1 (± 0.0) MB/sec fillsync : 805.625 micros/op 1241 ops/sec 80.563 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync [AVG 3 runs] : 1287 (± 51) ops/sec; 0.1 (± 0.0) MB/sec fillsync [AVG 3 runs] : 1287 (± 51) ops/sec; 0.1 (± 0.0) MB/sec fillsync [MEDIAN 3 runs] : 1287 ops/sec; 0.1 MB/sec ``` Before this PR and after facebook#10087 ```bash fillsync : 1479.601 micros/op 675 ops/sec 147.960 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync : 1626.080 micros/op 614 ops/sec 162.608 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync [AVG 2 runs] : 645 (± 59) ops/sec; 0.1 (± 0.0) MB/sec fillsync : 1588.402 micros/op 629 ops/sec 158.840 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync [AVG 3 runs] : 640 (± 35) ops/sec; 0.1 (± 0.0) MB/sec fillsync [AVG 3 runs] : 640 (± 35) ops/sec; 0.1 (± 0.0) MB/sec fillsync [MEDIAN 3 runs] : 629 ops/sec; 0.1 MB/sec ``` After this PR ```bash fillsync : 749.621 micros/op 1334 ops/sec 74.962 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync : 865.577 micros/op 1155 ops/sec 86.558 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync [AVG 2 runs] : 1244 (± 175) ops/sec; 0.1 (± 0.0) MB/sec fillsync : 845.837 micros/op 1182 ops/sec 84.584 seconds 100000 operations; 0.1 MB/s (100 ops) fillsync [AVG 3 runs] : 1223 (± 109) ops/sec; 0.1 (± 0.0) MB/sec fillsync [AVG 3 runs] : 1223 (± 109) ops/sec; 0.1 (± 0.0) MB/sec fillsync [MEDIAN 3 runs] : 1182 ops/sec; 0.1 MB/sec ``` Reviewed By: ajkr Differential Revision: D37725212 Pulled By: riversand963 fbshipit-source-id: 8fa7d13b3c7662be5d56351c42caf3266af937ae Signed-off-by: tabokie <[email protected]>
1 parent 22304c4 commit 1022df7

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

HISTORY.md

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
* Improved the SstDumpTool to read the comparator from table properties and use it to read the SST File.
2020
* Add an extra sanity check in `GetSortedWalFiles()` (also used by `GetLiveFilesStorageInfo()`, `BackupEngine`, and `Checkpoint`) to reduce risk of successfully created backup or checkpoint failing to open because of missing WAL file.
2121

22+
## Behavior Changes
23+
* For track_and_verify_wals_in_manifest, revert to the original behavior before #10087: syncing of live WAL file is not tracked, and we track only the synced sizes of **closed** WALs. (PR #10330).
24+
2225
## 6.29.5 (03/29/2022)
2326
### Bug Fixes
2427
* Fixed a race condition for `alive_log_files_` in non-two-write-queues mode. The race is between the write_thread_ in WriteToWAL() and another thread executing `FindObsoleteFiles()`. The race condition will be caught if `__glibcxx_requires_nonempty` is enabled.

db/db_basic_test.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -3704,7 +3704,9 @@ TEST_F(DBBasicTest, VerifyFileChecksums) {
37043704
ASSERT_TRUE(db_->VerifyFileChecksums(ReadOptions()).IsInvalidArgument());
37053705
}
37063706

3707-
TEST_F(DBBasicTest, ManualWalSync) {
3707+
// TODO: re-enable after we provide finer-grained control for WAL tracking to
3708+
// meet the needs of different use cases, durability levels and recovery modes.
3709+
TEST_F(DBBasicTest, DISABLED_ManualWalSync) {
37083710
Options options = CurrentOptions();
37093711
options.track_and_verify_wals_in_manifest = true;
37103712
options.wal_recovery_mode = WALRecoveryMode::kAbsoluteConsistency;

db/db_impl/db_impl.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1443,12 +1443,12 @@ Status DBImpl::MarkLogsSynced(uint64_t up_to, bool synced_dir) {
14431443
for (auto it = logs_.begin(); it != logs_.end() && it->number <= up_to;) {
14441444
auto& wal = *it;
14451445
assert(wal.IsSyncing());
1446-
if (immutable_db_options_.track_and_verify_wals_in_manifest &&
1447-
wal.GetPreSyncSize() > 0) {
1448-
synced_wals.AddWal(wal.number, WalMetadata(wal.GetPreSyncSize()));
1449-
}
14501446

14511447
if (logs_.size() > 1) {
1448+
if (immutable_db_options_.track_and_verify_wals_in_manifest &&
1449+
wal.GetPreSyncSize() > 0) {
1450+
synced_wals.AddWal(wal.number, WalMetadata(wal.GetPreSyncSize()));
1451+
}
14521452
logs_to_free_.push_back(wal.ReleaseWriter());
14531453
// To modify logs_ both mutex_ and log_write_mutex_ must be held
14541454
InstrumentedMutexLock l(&log_write_mutex_);

include/rocksdb/options.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,17 @@ struct DBOptions {
502502
bool flush_verify_memtable_count = true;
503503

504504
// If true, the log numbers and sizes of the synced WALs are tracked
505-
// in MANIFEST, then during DB recovery, if a synced WAL is missing
505+
// in MANIFEST. During DB recovery, if a synced WAL is missing
506506
// from disk, or the WAL's size does not match the recorded size in
507507
// MANIFEST, an error will be reported and the recovery will be aborted.
508508
//
509+
// This is one additional protection against WAL corruption besides the
510+
// per-WAL-entry checksum.
511+
//
509512
// Note that this option does not work with secondary instance.
513+
// Currently, only syncing closed WALs are tracked. Calling `DB::SyncWAL()`,
514+
// etc. or writing with `WriteOptions::sync=true` to sync the live WAL is not
515+
// tracked for performance/efficiency reasons.
510516
//
511517
// Default: false
512518
bool track_and_verify_wals_in_manifest = false;

tools/db_bench_tool.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,9 @@ DEFINE_string(
15691569
encryption_method, "",
15701570
"If non-empty, enable encryption with the specific encryption method.");
15711571

1572+
DEFINE_bool(track_and_verify_wals_in_manifest, false,
1573+
"If true, enable WAL tracking in the MANIFEST");
1574+
15721575
namespace ROCKSDB_NAMESPACE {
15731576
namespace {
15741577
static Status CreateMemTableRepFactory(
@@ -4445,6 +4448,9 @@ class Benchmark {
44454448
options.comparator = test::BytewiseComparatorWithU64TsWrapper();
44464449
}
44474450

4451+
options.track_and_verify_wals_in_manifest =
4452+
FLAGS_track_and_verify_wals_in_manifest;
4453+
44484454
// Integrated BlobDB
44494455
options.enable_blob_files = FLAGS_enable_blob_files;
44504456
options.min_blob_size = FLAGS_min_blob_size;

0 commit comments

Comments
 (0)