]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db_stress_tool/db_stress_gflags.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / db_stress_tool / db_stress_gflags.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5 //
6 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file. See the AUTHORS file for names of contributors.
9
10 #ifdef GFLAGS
11 #include "db_stress_tool/db_stress_common.h"
12
13 static bool ValidateUint32Range(const char* flagname, uint64_t value) {
14 if (value > std::numeric_limits<uint32_t>::max()) {
15 fprintf(stderr, "Invalid value for --%s: %lu, overflow\n", flagname,
16 (unsigned long)value);
17 return false;
18 }
19 return true;
20 }
21
22 DEFINE_uint64(seed, 2341234,
23 "Seed for PRNG. When --nooverwritepercent is "
24 "nonzero and --expected_values_dir is nonempty, this value "
25 "must be fixed across invocations.");
26 static const bool FLAGS_seed_dummy __attribute__((__unused__)) =
27 RegisterFlagValidator(&FLAGS_seed, &ValidateUint32Range);
28
29 DEFINE_bool(read_only, false, "True if open DB in read-only mode during tests");
30
31 DEFINE_int64(max_key, 1 * KB * KB,
32 "Max number of key/values to place in database");
33
34 DEFINE_int32(max_key_len, 3, "Maximum length of a key in 8-byte units");
35
36 DEFINE_string(key_len_percent_dist, "",
37 "Percentages of keys of various lengths. For example, 1,30,69 "
38 "means 1% of keys are 8 bytes, 30% are 16 bytes, and 69% are "
39 "24 bytes. If not specified, it will be evenly distributed");
40
41 DEFINE_int32(key_window_scale_factor, 10,
42 "This value will be multiplied by 100 to come up with a window "
43 "size for varying the key length");
44
45 DEFINE_int32(column_families, 10, "Number of column families");
46
47 DEFINE_double(
48 hot_key_alpha, 0,
49 "Use Zipfian distribution to generate the key "
50 "distribution. If it is not specified, write path will use random "
51 "distribution to generate the keys. The parameter is [0, double_max]). "
52 "However, the larger alpha is, the more shewed will be. If alpha is "
53 "larger than 2, it is likely that only 1 key will be accessed. The "
54 "Recommended value is [0.8-1.5]. The distribution is also related to "
55 "max_key and total iterations of generating the hot key. ");
56
57 DEFINE_string(
58 options_file, "",
59 "The path to a RocksDB options file. If specified, then db_stress will "
60 "run with the RocksDB options in the default column family of the "
61 "specified options file. Note that, when an options file is provided, "
62 "db_stress will ignore the flag values for all options that may be passed "
63 "via options file.");
64
65 DEFINE_int64(
66 active_width, 0,
67 "Number of keys in active span of the key-range at any given time. The "
68 "span begins with its left endpoint at key 0, gradually moves rightwards, "
69 "and ends with its right endpoint at max_key. If set to 0, active_width "
70 "will be sanitized to be equal to max_key.");
71
72 // TODO(noetzli) Add support for single deletes
73 DEFINE_bool(test_batches_snapshots, false,
74 "If set, the test uses MultiGet(), MultiPut() and MultiDelete()"
75 " which read/write/delete multiple keys in a batch. In this mode,"
76 " we do not verify db content by comparing the content with the "
77 "pre-allocated array. Instead, we do partial verification inside"
78 " MultiGet() by checking various values in a batch. Benefit of"
79 " this mode:\n"
80 "\t(a) No need to acquire mutexes during writes (less cache "
81 "flushes in multi-core leading to speed up)\n"
82 "\t(b) No long validation at the end (more speed up)\n"
83 "\t(c) Test snapshot and atomicity of batch writes");
84
85 DEFINE_bool(atomic_flush, false,
86 "If set, enables atomic flush in the options.\n");
87
88 DEFINE_int32(
89 manual_wal_flush_one_in, 0,
90 "If non-zero, then `FlushWAL(bool sync)`, where `bool sync` is randomly "
91 "decided, will be explictly called in db stress once for every N ops "
92 "on average. Setting `manual_wal_flush_one_in` to be greater than 0 "
93 "implies `Options::manual_wal_flush = true` is set.");
94
95 DEFINE_bool(test_cf_consistency, false,
96 "If set, runs the stress test dedicated to verifying writes to "
97 "multiple column families are consistent. Setting this implies "
98 "`atomic_flush=true` is set true if `disable_wal=false`.\n");
99
100 DEFINE_bool(test_multi_ops_txns, false,
101 "If set, runs stress test dedicated to verifying multi-ops "
102 "transactions on a simple relational table with primary and "
103 "secondary index.");
104
105 DEFINE_int32(threads, 32, "Number of concurrent threads to run.");
106
107 DEFINE_int32(ttl, -1,
108 "Opens the db with this ttl value if this is not -1. "
109 "Carefully specify a large value such that verifications on "
110 "deleted values don't fail");
111
112 DEFINE_int32(value_size_mult, 8,
113 "Size of value will be this number times rand_int(1,3) bytes");
114
115 DEFINE_int32(compaction_readahead_size, 0, "Compaction readahead size");
116
117 DEFINE_bool(enable_pipelined_write, false, "Pipeline WAL/memtable writes");
118
119 DEFINE_bool(verify_before_write, false, "Verify before write");
120
121 DEFINE_bool(histogram, false, "Print histogram of operation timings");
122
123 DEFINE_bool(destroy_db_initially, true,
124 "Destroys the database dir before start if this is true");
125
126 DEFINE_bool(verbose, false, "Verbose");
127
128 DEFINE_bool(progress_reports, true,
129 "If true, db_stress will report number of finished operations");
130
131 DEFINE_uint64(db_write_buffer_size,
132 ROCKSDB_NAMESPACE::Options().db_write_buffer_size,
133 "Number of bytes to buffer in all memtables before compacting");
134
135 DEFINE_int32(
136 write_buffer_size,
137 static_cast<int32_t>(ROCKSDB_NAMESPACE::Options().write_buffer_size),
138 "Number of bytes to buffer in memtable before compacting");
139
140 DEFINE_int32(max_write_buffer_number,
141 ROCKSDB_NAMESPACE::Options().max_write_buffer_number,
142 "The number of in-memory memtables. "
143 "Each memtable is of size FLAGS_write_buffer_size.");
144
145 DEFINE_int32(min_write_buffer_number_to_merge,
146 ROCKSDB_NAMESPACE::Options().min_write_buffer_number_to_merge,
147 "The minimum number of write buffers that will be merged together "
148 "before writing to storage. This is cheap because it is an "
149 "in-memory merge. If this feature is not enabled, then all these "
150 "write buffers are flushed to L0 as separate files and this "
151 "increases read amplification because a get request has to check "
152 "in all of these files. Also, an in-memory merge may result in "
153 "writing less data to storage if there are duplicate records in"
154 " each of these individual write buffers.");
155
156 DEFINE_int32(max_write_buffer_number_to_maintain,
157 ROCKSDB_NAMESPACE::Options().max_write_buffer_number_to_maintain,
158 "The total maximum number of write buffers to maintain in memory "
159 "including copies of buffers that have already been flushed. "
160 "Unlike max_write_buffer_number, this parameter does not affect "
161 "flushing. This controls the minimum amount of write history "
162 "that will be available in memory for conflict checking when "
163 "Transactions are used. If this value is too low, some "
164 "transactions may fail at commit time due to not being able to "
165 "determine whether there were any write conflicts. Setting this "
166 "value to 0 will cause write buffers to be freed immediately "
167 "after they are flushed. If this value is set to -1, "
168 "'max_write_buffer_number' will be used.");
169
170 DEFINE_int64(max_write_buffer_size_to_maintain,
171 ROCKSDB_NAMESPACE::Options().max_write_buffer_size_to_maintain,
172 "The total maximum size of write buffers to maintain in memory "
173 "including copies of buffers that have already been flushed. "
174 "Unlike max_write_buffer_number, this parameter does not affect "
175 "flushing. This controls the minimum amount of write history "
176 "that will be available in memory for conflict checking when "
177 "Transactions are used. If this value is too low, some "
178 "transactions may fail at commit time due to not being able to "
179 "determine whether there were any write conflicts. Setting this "
180 "value to 0 will cause write buffers to be freed immediately "
181 "after they are flushed. If this value is set to -1, "
182 "'max_write_buffer_number' will be used.");
183
184 DEFINE_double(memtable_prefix_bloom_size_ratio,
185 ROCKSDB_NAMESPACE::Options().memtable_prefix_bloom_size_ratio,
186 "creates prefix blooms for memtables, each with size "
187 "`write_buffer_size * memtable_prefix_bloom_size_ratio`.");
188
189 DEFINE_bool(memtable_whole_key_filtering,
190 ROCKSDB_NAMESPACE::Options().memtable_whole_key_filtering,
191 "Enable whole key filtering in memtables.");
192
193 DEFINE_int32(open_files, ROCKSDB_NAMESPACE::Options().max_open_files,
194 "Maximum number of files to keep open at the same time "
195 "(use default if == 0)");
196
197 DEFINE_int64(compressed_cache_size, 0,
198 "Number of bytes to use as a cache of compressed data."
199 " 0 means use default settings.");
200
201 DEFINE_int32(
202 compressed_cache_numshardbits, -1,
203 "Number of shards for the compressed block cache is 2 ** "
204 "compressed_cache_numshardbits. Negative value means default settings. "
205 "This is applied only if compressed_cache_size is greater than 0.");
206
207 DEFINE_int32(compaction_style, ROCKSDB_NAMESPACE::Options().compaction_style,
208 "");
209
210 DEFINE_int32(compaction_pri, ROCKSDB_NAMESPACE::Options().compaction_pri,
211 "Which file from a level should be picked to merge to the next "
212 "level in level-based compaction");
213
214 DEFINE_int32(num_levels, ROCKSDB_NAMESPACE::Options().num_levels,
215 "Number of levels in the DB");
216
217 DEFINE_int32(level0_file_num_compaction_trigger,
218 ROCKSDB_NAMESPACE::Options().level0_file_num_compaction_trigger,
219 "Level0 compaction start trigger");
220
221 DEFINE_int32(level0_slowdown_writes_trigger,
222 ROCKSDB_NAMESPACE::Options().level0_slowdown_writes_trigger,
223 "Number of files in level-0 that will slow down writes");
224
225 DEFINE_int32(level0_stop_writes_trigger,
226 ROCKSDB_NAMESPACE::Options().level0_stop_writes_trigger,
227 "Number of files in level-0 that will trigger put stop.");
228
229 DEFINE_int32(block_size,
230 static_cast<int32_t>(
231 ROCKSDB_NAMESPACE::BlockBasedTableOptions().block_size),
232 "Number of bytes in a block.");
233
234 DEFINE_int32(format_version,
235 static_cast<int32_t>(
236 ROCKSDB_NAMESPACE::BlockBasedTableOptions().format_version),
237 "Format version of SST files.");
238
239 DEFINE_int32(
240 index_block_restart_interval,
241 ROCKSDB_NAMESPACE::BlockBasedTableOptions().index_block_restart_interval,
242 "Number of keys between restart points "
243 "for delta encoding of keys in index block.");
244
245 DEFINE_bool(disable_auto_compactions,
246 ROCKSDB_NAMESPACE::Options().disable_auto_compactions,
247 "If true, RocksDB internally will not trigger compactions.");
248
249 DEFINE_int32(max_background_compactions,
250 ROCKSDB_NAMESPACE::Options().max_background_compactions,
251 "The maximum number of concurrent background compactions "
252 "that can occur in parallel.");
253
254 DEFINE_int32(num_bottom_pri_threads, 0,
255 "The number of threads in the bottom-priority thread pool (used "
256 "by universal compaction only).");
257
258 DEFINE_int32(compaction_thread_pool_adjust_interval, 0,
259 "The interval (in milliseconds) to adjust compaction thread pool "
260 "size. Don't change it periodically if the value is 0.");
261
262 DEFINE_int32(compaction_thread_pool_variations, 2,
263 "Range of background thread pool size variations when adjusted "
264 "periodically.");
265
266 DEFINE_int32(max_background_flushes,
267 ROCKSDB_NAMESPACE::Options().max_background_flushes,
268 "The maximum number of concurrent background flushes "
269 "that can occur in parallel.");
270
271 DEFINE_int32(universal_size_ratio, 0,
272 "The ratio of file sizes that trigger"
273 " compaction in universal style");
274
275 DEFINE_int32(universal_min_merge_width, 0,
276 "The minimum number of files to "
277 "compact in universal style compaction");
278
279 DEFINE_int32(universal_max_merge_width, 0,
280 "The max number of files to compact"
281 " in universal style compaction");
282
283 DEFINE_int32(universal_max_size_amplification_percent, 0,
284 "The max size amplification for universal style compaction");
285
286 DEFINE_int32(clear_column_family_one_in, 1000000,
287 "With a chance of 1/N, delete a column family and then recreate "
288 "it again. If N == 0, never drop/create column families. "
289 "When test_batches_snapshots is true, this flag has no effect");
290
291 DEFINE_int32(get_live_files_one_in, 1000000,
292 "With a chance of 1/N, call GetLiveFiles to verify if it returns "
293 "correctly. If N == 0, do not call the interface.");
294
295 DEFINE_int32(
296 get_sorted_wal_files_one_in, 1000000,
297 "With a chance of 1/N, call GetSortedWalFiles to verify if it returns "
298 "correctly. (Note that this API may legitimately return an error.) If N == "
299 "0, do not call the interface.");
300
301 DEFINE_int32(
302 get_current_wal_file_one_in, 1000000,
303 "With a chance of 1/N, call GetCurrentWalFile to verify if it returns "
304 "correctly. (Note that this API may legitimately return an error.) If N == "
305 "0, do not call the interface.");
306
307 DEFINE_int32(set_options_one_in, 0,
308 "With a chance of 1/N, change some random options");
309
310 DEFINE_int32(set_in_place_one_in, 0,
311 "With a chance of 1/N, toggle in place support option");
312
313 DEFINE_int64(cache_size, 2LL * KB * KB * KB,
314 "Number of bytes to use as a cache of uncompressed data.");
315
316 DEFINE_int32(cache_numshardbits, 6,
317 "Number of shards for the block cache"
318 " is 2 ** cache_numshardbits. Negative means use default settings."
319 " This is applied only if FLAGS_cache_size is greater than 0.");
320
321 DEFINE_bool(cache_index_and_filter_blocks, false,
322 "True if indexes/filters should be cached in block cache.");
323
324 DEFINE_bool(charge_compression_dictionary_building_buffer, false,
325 "Setting for "
326 "CacheEntryRoleOptions::charged of "
327 "CacheEntryRole::kCompressionDictionaryBuildingBuffer");
328
329 DEFINE_bool(charge_filter_construction, false,
330 "Setting for "
331 "CacheEntryRoleOptions::charged of "
332 "CacheEntryRole::kFilterConstruction");
333
334 DEFINE_bool(charge_table_reader, false,
335 "Setting for "
336 "CacheEntryRoleOptions::charged of "
337 "CacheEntryRole::kBlockBasedTableReader");
338
339 DEFINE_bool(charge_file_metadata, false,
340 "Setting for "
341 "CacheEntryRoleOptions::charged of "
342 "kFileMetadata");
343
344 DEFINE_bool(charge_blob_cache, false,
345 "Setting for "
346 "CacheEntryRoleOptions::charged of "
347 "kBlobCache");
348
349 DEFINE_int32(
350 top_level_index_pinning,
351 static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
352 "Type of pinning for top-level indexes into metadata partitions (see "
353 "`enum PinningTier` in table.h)");
354
355 DEFINE_int32(
356 partition_pinning,
357 static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
358 "Type of pinning for metadata partitions (see `enum PinningTier` in "
359 "table.h)");
360
361 DEFINE_int32(
362 unpartitioned_pinning,
363 static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
364 "Type of pinning for unpartitioned metadata blocks (see `enum PinningTier` "
365 "in table.h)");
366
367 DEFINE_string(cache_type, "lru_cache", "Type of block cache.");
368
369 DEFINE_uint64(subcompactions, 1,
370 "Maximum number of subcompactions to divide L0-L1 compactions "
371 "into.");
372
373 DEFINE_uint64(periodic_compaction_seconds, 1000,
374 "Files older than this value will be picked up for compaction.");
375
376 DEFINE_uint64(compaction_ttl, 1000,
377 "Files older than TTL will be compacted to the next level.");
378
379 DEFINE_bool(allow_concurrent_memtable_write, false,
380 "Allow multi-writers to update mem tables in parallel.");
381
382 DEFINE_double(experimental_mempurge_threshold, 0.0,
383 "Maximum estimated useful payload that triggers a "
384 "mempurge process to collect memtable garbage bytes.");
385
386 DEFINE_bool(enable_write_thread_adaptive_yield, true,
387 "Use a yielding spin loop for brief writer thread waits.");
388
389 #ifndef ROCKSDB_LITE
390 // Options for StackableDB-based BlobDB
391 DEFINE_bool(use_blob_db, false, "[Stacked BlobDB] Use BlobDB.");
392
393 DEFINE_uint64(
394 blob_db_min_blob_size,
395 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().min_blob_size,
396 "[Stacked BlobDB] Smallest blob to store in a file. Blobs "
397 "smaller than this will be inlined with the key in the LSM tree.");
398
399 DEFINE_uint64(
400 blob_db_bytes_per_sync,
401 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().bytes_per_sync,
402 "[Stacked BlobDB] Sync blob files once per every N bytes written.");
403
404 DEFINE_uint64(blob_db_file_size,
405 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().blob_file_size,
406 "[Stacked BlobDB] Target size of each blob file.");
407
408 DEFINE_bool(
409 blob_db_enable_gc,
410 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().enable_garbage_collection,
411 "[Stacked BlobDB] Enable BlobDB garbage collection.");
412
413 DEFINE_double(
414 blob_db_gc_cutoff,
415 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().garbage_collection_cutoff,
416 "[Stacked BlobDB] Cutoff ratio for BlobDB garbage collection.");
417 #endif // !ROCKSDB_LITE
418
419 // Options for integrated BlobDB
420 DEFINE_bool(allow_setting_blob_options_dynamically, false,
421 "[Integrated BlobDB] Allow setting blob options dynamically.");
422
423 DEFINE_bool(
424 enable_blob_files,
425 ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions().enable_blob_files,
426 "[Integrated BlobDB] Enable writing large values to separate blob files.");
427
428 DEFINE_uint64(min_blob_size,
429 ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions().min_blob_size,
430 "[Integrated BlobDB] The size of the smallest value to be stored "
431 "separately in a blob file.");
432
433 DEFINE_uint64(blob_file_size,
434 ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions().blob_file_size,
435 "[Integrated BlobDB] The size limit for blob files.");
436
437 DEFINE_string(blob_compression_type, "none",
438 "[Integrated BlobDB] The compression algorithm to use for large "
439 "values stored in blob files.");
440
441 DEFINE_bool(enable_blob_garbage_collection,
442 ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions()
443 .enable_blob_garbage_collection,
444 "[Integrated BlobDB] Enable blob garbage collection.");
445
446 DEFINE_double(blob_garbage_collection_age_cutoff,
447 ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions()
448 .blob_garbage_collection_age_cutoff,
449 "[Integrated BlobDB] The cutoff in terms of blob file age for "
450 "garbage collection.");
451
452 DEFINE_double(blob_garbage_collection_force_threshold,
453 ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions()
454 .blob_garbage_collection_force_threshold,
455 "[Integrated BlobDB] The threshold for the ratio of garbage in "
456 "the oldest blob files for forcing garbage collection.");
457
458 DEFINE_uint64(blob_compaction_readahead_size,
459 ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions()
460 .blob_compaction_readahead_size,
461 "[Integrated BlobDB] Compaction readahead for blob files.");
462
463 DEFINE_int32(
464 blob_file_starting_level,
465 ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions().blob_file_starting_level,
466 "[Integrated BlobDB] Enable writing blob files during flushes and "
467 "compactions starting from the specified level.");
468
469 DEFINE_bool(use_blob_cache, false, "[Integrated BlobDB] Enable blob cache.");
470
471 DEFINE_bool(
472 use_shared_block_and_blob_cache, true,
473 "[Integrated BlobDB] Use a shared backing cache for both block "
474 "cache and blob cache. It only takes effect if use_blob_cache is enabled.");
475
476 DEFINE_uint64(
477 blob_cache_size, 2LL * KB * KB * KB,
478 "[Integrated BlobDB] Number of bytes to use as a cache of blobs. It only "
479 "takes effect if the block and blob caches are different "
480 "(use_shared_block_and_blob_cache = false).");
481
482 DEFINE_int32(blob_cache_numshardbits, 6,
483 "[Integrated BlobDB] Number of shards for the blob cache is 2 ** "
484 "blob_cache_numshardbits. Negative means use default settings. "
485 "It only takes effect if blob_cache_size is greater than 0, and "
486 "the block and blob caches are different "
487 "(use_shared_block_and_blob_cache = false).");
488
489 DEFINE_int32(prepopulate_blob_cache, 0,
490 "[Integrated BlobDB] Pre-populate hot/warm blobs in blob cache. 0 "
491 "to disable and 1 to insert during flush.");
492
493 DEFINE_bool(enable_tiered_storage, false, "Set last_level_temperature");
494
495 DEFINE_int64(preclude_last_level_data_seconds, 0,
496 "Preclude data from the last level. Used with tiered storage "
497 "feature to preclude new data from comacting to the last level.");
498
499 DEFINE_int64(
500 preserve_internal_time_seconds, 0,
501 "Preserve internal time information which is attached to each SST.");
502
503 static const bool FLAGS_subcompactions_dummy __attribute__((__unused__)) =
504 RegisterFlagValidator(&FLAGS_subcompactions, &ValidateUint32Range);
505
506 static bool ValidateInt32Positive(const char* flagname, int32_t value) {
507 if (value < 0) {
508 fprintf(stderr, "Invalid value for --%s: %d, must be >=0\n", flagname,
509 value);
510 return false;
511 }
512 return true;
513 }
514 DEFINE_int32(reopen, 10, "Number of times database reopens");
515 static const bool FLAGS_reopen_dummy __attribute__((__unused__)) =
516 RegisterFlagValidator(&FLAGS_reopen, &ValidateInt32Positive);
517
518 DEFINE_double(bloom_bits, 10,
519 "Bloom filter bits per key. "
520 "Negative means use default settings.");
521
522 DEFINE_int32(
523 ribbon_starting_level, 999,
524 "Use Bloom filter on levels below specified and Ribbon beginning on level "
525 "specified. Flush is considered level -1. 999 or more -> always Bloom. 0 "
526 "-> Ribbon except Bloom for flush. -1 -> always Ribbon.");
527
528 DEFINE_bool(partition_filters, false,
529 "use partitioned filters "
530 "for block-based table");
531
532 DEFINE_bool(
533 optimize_filters_for_memory,
534 ROCKSDB_NAMESPACE::BlockBasedTableOptions().optimize_filters_for_memory,
535 "Minimize memory footprint of filters");
536
537 DEFINE_bool(
538 detect_filter_construct_corruption,
539 ROCKSDB_NAMESPACE::BlockBasedTableOptions()
540 .detect_filter_construct_corruption,
541 "Detect corruption during new Bloom Filter and Ribbon Filter construction");
542
543 DEFINE_int32(
544 index_type,
545 static_cast<int32_t>(
546 ROCKSDB_NAMESPACE::BlockBasedTableOptions().index_type),
547 "Type of block-based table index (see `enum IndexType` in table.h)");
548
549 DEFINE_int32(
550 data_block_index_type,
551 static_cast<int32_t>(
552 ROCKSDB_NAMESPACE::BlockBasedTableOptions().data_block_index_type),
553 "Index type for data blocks (see `enum DataBlockIndexType` in table.h)");
554
555 DEFINE_string(db, "", "Use the db with the following name.");
556
557 DEFINE_string(secondaries_base, "",
558 "Use this path as the base path for secondary instances.");
559
560 DEFINE_bool(test_secondary, false,
561 "If true, start an additional secondary instance which can be used "
562 "for verification.");
563
564 DEFINE_string(
565 expected_values_dir, "",
566 "Dir where files containing info about the latest/historical values will "
567 "be stored. If provided and non-empty, the DB state will be verified "
568 "against values from these files after recovery. --max_key and "
569 "--column_family must be kept the same across invocations of this program "
570 "that use the same --expected_values_dir. Currently historical values are "
571 "only tracked when --sync_fault_injection is set. See --seed and "
572 "--nooverwritepercent for further requirements.");
573
574 DEFINE_bool(verify_checksum, false,
575 "Verify checksum for every block read from storage");
576
577 DEFINE_bool(mmap_read, ROCKSDB_NAMESPACE::Options().allow_mmap_reads,
578 "Allow reads to occur via mmap-ing files");
579
580 DEFINE_bool(mmap_write, ROCKSDB_NAMESPACE::Options().allow_mmap_writes,
581 "Allow writes to occur via mmap-ing files");
582
583 DEFINE_bool(use_direct_reads, ROCKSDB_NAMESPACE::Options().use_direct_reads,
584 "Use O_DIRECT for reading data");
585
586 DEFINE_bool(use_direct_io_for_flush_and_compaction,
587 ROCKSDB_NAMESPACE::Options().use_direct_io_for_flush_and_compaction,
588 "Use O_DIRECT for writing data");
589
590 DEFINE_bool(mock_direct_io, false,
591 "Mock direct IO by not using O_DIRECT for direct IO read");
592
593 DEFINE_bool(statistics, false, "Create database statistics");
594
595 DEFINE_bool(sync, false, "Sync all writes to disk");
596
597 DEFINE_bool(use_fsync, false, "If true, issue fsync instead of fdatasync");
598
599 DEFINE_uint64(bytes_per_sync, ROCKSDB_NAMESPACE::Options().bytes_per_sync,
600 "If nonzero, sync SST file data incrementally after every "
601 "`bytes_per_sync` bytes are written");
602
603 DEFINE_uint64(wal_bytes_per_sync,
604 ROCKSDB_NAMESPACE::Options().wal_bytes_per_sync,
605 "If nonzero, sync WAL file data incrementally after every "
606 "`bytes_per_sync` bytes are written");
607
608 DEFINE_int32(kill_random_test, 0,
609 "If non-zero, kill at various points in source code with "
610 "probability 1/this");
611 static const bool FLAGS_kill_random_test_dummy __attribute__((__unused__)) =
612 RegisterFlagValidator(&FLAGS_kill_random_test, &ValidateInt32Positive);
613
614 DEFINE_string(kill_exclude_prefixes, "",
615 "If non-empty, kill points with prefix in the list given will be"
616 " skipped. Items are comma-separated.");
617 extern std::vector<std::string> rocksdb_kill_exclude_prefixes;
618
619 DEFINE_bool(disable_wal, false, "If true, do not write WAL for write.");
620
621 DEFINE_uint64(recycle_log_file_num,
622 ROCKSDB_NAMESPACE::Options().recycle_log_file_num,
623 "Number of old WAL files to keep around for later recycling");
624
625 DEFINE_int64(target_file_size_base,
626 ROCKSDB_NAMESPACE::Options().target_file_size_base,
627 "Target level-1 file size for compaction");
628
629 DEFINE_int32(target_file_size_multiplier, 1,
630 "A multiplier to compute target level-N file size (N >= 2)");
631
632 DEFINE_uint64(max_bytes_for_level_base,
633 ROCKSDB_NAMESPACE::Options().max_bytes_for_level_base,
634 "Max bytes for level-1");
635
636 DEFINE_double(max_bytes_for_level_multiplier, 2,
637 "A multiplier to compute max bytes for level-N (N >= 2)");
638
639 DEFINE_int32(range_deletion_width, 10,
640 "The width of the range deletion intervals.");
641
642 DEFINE_uint64(rate_limiter_bytes_per_sec, 0, "Set options.rate_limiter value.");
643
644 DEFINE_bool(rate_limit_bg_reads, false,
645 "Use options.rate_limiter on compaction reads");
646
647 DEFINE_bool(rate_limit_user_ops, false,
648 "When true use Env::IO_USER priority level to charge internal rate "
649 "limiter for reads associated with user operations.");
650
651 DEFINE_bool(rate_limit_auto_wal_flush, false,
652 "When true use Env::IO_USER priority level to charge internal rate "
653 "limiter for automatic WAL flush (`Options::manual_wal_flush` == "
654 "false) after the user "
655 "write operation.");
656
657 DEFINE_uint64(sst_file_manager_bytes_per_sec, 0,
658 "Set `Options::sst_file_manager` to delete at this rate. By "
659 "default the deletion rate is unbounded.");
660
661 DEFINE_uint64(sst_file_manager_bytes_per_truncate, 0,
662 "Set `Options::sst_file_manager` to delete in chunks of this "
663 "many bytes. By default whole files will be deleted.");
664
665 DEFINE_bool(use_txn, false,
666 "Use TransactionDB. Currently the default write policy is "
667 "TxnDBWritePolicy::WRITE_PREPARED");
668
669 DEFINE_uint64(txn_write_policy, 0,
670 "The transaction write policy. Default is "
671 "TxnDBWritePolicy::WRITE_COMMITTED. Note that this should not be "
672 "changed accross crashes.");
673
674 DEFINE_bool(unordered_write, false,
675 "Turn on the unordered_write feature. This options is currently "
676 "tested only in combination with use_txn=true and "
677 "txn_write_policy=TxnDBWritePolicy::WRITE_PREPARED.");
678
679 DEFINE_int32(backup_one_in, 0,
680 "If non-zero, then CreateNewBackup() will be called once for "
681 "every N operations on average. 0 indicates CreateNewBackup() "
682 "is disabled.");
683
684 DEFINE_uint64(backup_max_size, 100 * 1024 * 1024,
685 "If non-zero, skip checking backup/restore when DB size in "
686 "bytes exceeds this setting.");
687
688 DEFINE_int32(checkpoint_one_in, 0,
689 "If non-zero, then CreateCheckpoint() will be called once for "
690 "every N operations on average. 0 indicates CreateCheckpoint() "
691 "is disabled.");
692
693 DEFINE_int32(ingest_external_file_one_in, 0,
694 "If non-zero, then IngestExternalFile() will be called once for "
695 "every N operations on average. 0 indicates IngestExternalFile() "
696 "is disabled.");
697
698 DEFINE_int32(ingest_external_file_width, 100,
699 "The width of the ingested external files.");
700
701 DEFINE_int32(compact_files_one_in, 0,
702 "If non-zero, then CompactFiles() will be called once for every N "
703 "operations on average. 0 indicates CompactFiles() is disabled.");
704
705 DEFINE_int32(compact_range_one_in, 0,
706 "If non-zero, then CompactRange() will be called once for every N "
707 "operations on average. 0 indicates CompactRange() is disabled.");
708
709 DEFINE_int32(mark_for_compaction_one_file_in, 0,
710 "A `TablePropertiesCollectorFactory` will be registered, which "
711 "creates a `TablePropertiesCollector` with `NeedCompact()` "
712 "returning true once for every N files on average. 0 or negative "
713 "mean `NeedCompact()` always returns false.");
714
715 DEFINE_int32(flush_one_in, 0,
716 "If non-zero, then Flush() will be called once for every N ops "
717 "on average. 0 indicates calls to Flush() are disabled.");
718
719 DEFINE_int32(pause_background_one_in, 0,
720 "If non-zero, then PauseBackgroundWork()+Continue will be called "
721 "once for every N ops on average. 0 disables.");
722
723 DEFINE_int32(compact_range_width, 10000,
724 "The width of the ranges passed to CompactRange().");
725
726 DEFINE_int32(acquire_snapshot_one_in, 0,
727 "If non-zero, then acquires a snapshot once every N operations on "
728 "average.");
729
730 DEFINE_bool(compare_full_db_state_snapshot, false,
731 "If set we compare state of entire db (in one of the threads) with"
732 "each snapshot.");
733
734 DEFINE_uint64(snapshot_hold_ops, 0,
735 "If non-zero, then releases snapshots N operations after they're "
736 "acquired.");
737
738 DEFINE_bool(long_running_snapshots, false,
739 "If set, hold on some some snapshots for much longer time.");
740
741 DEFINE_bool(use_multiget, false,
742 "If set, use the batched MultiGet API for reads");
743
744 static bool ValidateInt32Percent(const char* flagname, int32_t value) {
745 if (value < 0 || value > 100) {
746 fprintf(stderr, "Invalid value for --%s: %d, 0<= pct <=100 \n", flagname,
747 value);
748 return false;
749 }
750 return true;
751 }
752
753 DEFINE_int32(readpercent, 10,
754 "Ratio of reads to total workload (expressed as a percentage)");
755 static const bool FLAGS_readpercent_dummy __attribute__((__unused__)) =
756 RegisterFlagValidator(&FLAGS_readpercent, &ValidateInt32Percent);
757
758 DEFINE_int32(prefixpercent, 20,
759 "Ratio of prefix iterators to total workload (expressed as a"
760 " percentage)");
761 static const bool FLAGS_prefixpercent_dummy __attribute__((__unused__)) =
762 RegisterFlagValidator(&FLAGS_prefixpercent, &ValidateInt32Percent);
763
764 DEFINE_int32(writepercent, 45,
765 "Ratio of writes to total workload (expressed as a percentage)");
766 static const bool FLAGS_writepercent_dummy __attribute__((__unused__)) =
767 RegisterFlagValidator(&FLAGS_writepercent, &ValidateInt32Percent);
768
769 DEFINE_int32(delpercent, 15,
770 "Ratio of deletes to total workload (expressed as a percentage)");
771 static const bool FLAGS_delpercent_dummy __attribute__((__unused__)) =
772 RegisterFlagValidator(&FLAGS_delpercent, &ValidateInt32Percent);
773
774 DEFINE_int32(delrangepercent, 0,
775 "Ratio of range deletions to total workload (expressed as a "
776 "percentage). Cannot be used with test_batches_snapshots");
777 static const bool FLAGS_delrangepercent_dummy __attribute__((__unused__)) =
778 RegisterFlagValidator(&FLAGS_delrangepercent, &ValidateInt32Percent);
779
780 DEFINE_int32(nooverwritepercent, 60,
781 "Ratio of keys without overwrite to total workload (expressed as "
782 "a percentage). When --expected_values_dir is nonempty, must "
783 "keep this value constant across invocations.");
784 static const bool FLAGS_nooverwritepercent_dummy __attribute__((__unused__)) =
785 RegisterFlagValidator(&FLAGS_nooverwritepercent, &ValidateInt32Percent);
786
787 DEFINE_int32(iterpercent, 10,
788 "Ratio of iterations to total workload"
789 " (expressed as a percentage)");
790 static const bool FLAGS_iterpercent_dummy __attribute__((__unused__)) =
791 RegisterFlagValidator(&FLAGS_iterpercent, &ValidateInt32Percent);
792
793 DEFINE_uint64(num_iterations, 10, "Number of iterations per MultiIterate run");
794 static const bool FLAGS_num_iterations_dummy __attribute__((__unused__)) =
795 RegisterFlagValidator(&FLAGS_num_iterations, &ValidateUint32Range);
796
797 DEFINE_int32(
798 customopspercent, 0,
799 "Ratio of custom operations to total workload (expressed as a percentage)");
800
801 DEFINE_string(compression_type, "snappy",
802 "Algorithm to use to compress the database");
803
804 DEFINE_int32(compression_max_dict_bytes, 0,
805 "Maximum size of dictionary used to prime the compression "
806 "library.");
807
808 DEFINE_int32(compression_zstd_max_train_bytes, 0,
809 "Maximum size of training data passed to zstd's dictionary "
810 "trainer.");
811
812 DEFINE_int32(compression_parallel_threads, 1,
813 "Number of threads for parallel compression.");
814
815 DEFINE_uint64(compression_max_dict_buffer_bytes, 0,
816 "Buffering limit for SST file data to sample for dictionary "
817 "compression.");
818
819 DEFINE_bool(
820 compression_use_zstd_dict_trainer, true,
821 "Use zstd's trainer to generate dictionary. If the options is false, "
822 "zstd's finalizeDictionary() API is used to generate dictionary. "
823 "ZSTD 1.4.5+ is required. If ZSTD 1.4.5+ is not linked with the binary, "
824 "this flag will have the default value true.");
825
826 DEFINE_string(bottommost_compression_type, "disable",
827 "Algorithm to use to compress bottommost level of the database. "
828 "\"disable\" means disabling the feature");
829
830 DEFINE_string(checksum_type, "kCRC32c", "Algorithm to use to checksum blocks");
831
832 DEFINE_string(env_uri, "",
833 "URI for env lookup. Mutually exclusive with --fs_uri");
834
835 DEFINE_string(fs_uri, "",
836 "URI for registry Filesystem lookup. Mutually exclusive"
837 " with --env_uri."
838 " Creates a default environment with the specified filesystem.");
839
840 DEFINE_uint64(ops_per_thread, 1200000, "Number of operations per thread.");
841 static const bool FLAGS_ops_per_thread_dummy __attribute__((__unused__)) =
842 RegisterFlagValidator(&FLAGS_ops_per_thread, &ValidateUint32Range);
843
844 DEFINE_uint64(log2_keys_per_lock, 2, "Log2 of number of keys per lock");
845 static const bool FLAGS_log2_keys_per_lock_dummy __attribute__((__unused__)) =
846 RegisterFlagValidator(&FLAGS_log2_keys_per_lock, &ValidateUint32Range);
847
848 DEFINE_uint64(max_manifest_file_size, 16384, "Maximum size of a MANIFEST file");
849
850 DEFINE_bool(in_place_update, false, "On true, does inplace update in memtable");
851
852 DEFINE_string(memtablerep, "skip_list", "");
853
854 inline static bool ValidatePrefixSize(const char* flagname, int32_t value) {
855 if (value < -1 || value > 8) {
856 fprintf(stderr, "Invalid value for --%s: %d. -1 <= PrefixSize <= 8\n",
857 flagname, value);
858 return false;
859 }
860 return true;
861 }
862 DEFINE_int32(prefix_size, 7,
863 "Control the prefix size for HashSkipListRep. "
864 "-1 is disabled.");
865 static const bool FLAGS_prefix_size_dummy __attribute__((__unused__)) =
866 RegisterFlagValidator(&FLAGS_prefix_size, &ValidatePrefixSize);
867
868 DEFINE_bool(use_merge, false,
869 "On true, replaces all writes with a Merge "
870 "that behaves like a Put");
871
872 DEFINE_uint32(use_put_entity_one_in, 0,
873 "If greater than zero, PutEntity will be used once per every N "
874 "write ops on average.");
875
876 DEFINE_bool(use_full_merge_v1, false,
877 "On true, use a merge operator that implement the deprecated "
878 "version of FullMerge");
879
880 DEFINE_int32(sync_wal_one_in, 0,
881 "If non-zero, then SyncWAL() will be called once for every N ops "
882 "on average. 0 indicates that calls to SyncWAL() are disabled.");
883
884 DEFINE_bool(avoid_unnecessary_blocking_io,
885 ROCKSDB_NAMESPACE::Options().avoid_unnecessary_blocking_io,
886 "If true, some expensive cleaning up operations will be moved from "
887 "user reads to high-pri background threads.");
888
889 DEFINE_bool(write_dbid_to_manifest,
890 ROCKSDB_NAMESPACE::Options().write_dbid_to_manifest,
891 "Write DB_ID to manifest");
892
893 DEFINE_bool(avoid_flush_during_recovery,
894 ROCKSDB_NAMESPACE::Options().avoid_flush_during_recovery,
895 "Avoid flush during recovery");
896
897 DEFINE_uint64(max_write_batch_group_size_bytes,
898 ROCKSDB_NAMESPACE::Options().max_write_batch_group_size_bytes,
899 "Max write batch group size");
900
901 DEFINE_bool(level_compaction_dynamic_level_bytes,
902 ROCKSDB_NAMESPACE::Options().level_compaction_dynamic_level_bytes,
903 "Use dynamic level");
904
905 DEFINE_int32(verify_checksum_one_in, 0,
906 "If non-zero, then DB::VerifyChecksum() will be called to do"
907 " checksum verification of all the files in the database once for"
908 " every N ops on average. 0 indicates that calls to"
909 " VerifyChecksum() are disabled.");
910 DEFINE_int32(verify_db_one_in, 0,
911 "If non-zero, call VerifyDb() once for every N ops. 0 indicates "
912 "that VerifyDb() will not be called in OperateDb(). Note that "
913 "enabling this can slow down tests.");
914
915 DEFINE_int32(continuous_verification_interval, 1000,
916 "While test is running, verify db every N milliseconds. 0 "
917 "disables continuous verification.");
918
919 DEFINE_int32(approximate_size_one_in, 64,
920 "If non-zero, DB::GetApproximateSizes() will be called against"
921 " random key ranges.");
922
923 DEFINE_int32(read_fault_one_in, 1000,
924 "On non-zero, enables fault injection on read");
925
926 DEFINE_int32(get_property_one_in, 1000,
927 "If non-zero, then DB::GetProperty() will be called to get various"
928 " properties for every N ops on average. 0 indicates that"
929 " GetProperty() will be not be called.");
930
931 DEFINE_bool(sync_fault_injection, false,
932 "If true, FaultInjectionTestFS will be used for write operations, "
933 "and unsynced data in DB will lost after crash. In such a case we "
934 "track DB changes in a trace file (\"*.trace\") in "
935 "--expected_values_dir for verifying there are no holes in the "
936 "recovered data.");
937
938 DEFINE_bool(best_efforts_recovery, false,
939 "If true, use best efforts recovery.");
940 DEFINE_bool(skip_verifydb, false,
941 "If true, skip VerifyDb() calls and Get()/Iterator verifications"
942 "against expected state.");
943
944 DEFINE_bool(enable_compaction_filter, false,
945 "If true, configures a compaction filter that returns a kRemove "
946 "decision for deleted keys.");
947
948 DEFINE_bool(paranoid_file_checks, true,
949 "After writing every SST file, reopen it and read all the keys "
950 "and validate checksums");
951
952 DEFINE_bool(fail_if_options_file_error, false,
953 "Fail operations that fail to detect or properly persist options "
954 "file.");
955
956 DEFINE_uint64(batch_protection_bytes_per_key, 0,
957 "If nonzero, enables integrity protection in `WriteBatch` at the "
958 "specified number of bytes per key. Currently the only supported "
959 "nonzero value is eight.");
960
961 DEFINE_uint32(
962 memtable_protection_bytes_per_key, 0,
963 "If nonzero, enables integrity protection in memtable entries at the "
964 "specified number of bytes per key. Currently the supported "
965 "nonzero values are 1, 2, 4 and 8.");
966
967 DEFINE_string(file_checksum_impl, "none",
968 "Name of an implementation for file_checksum_gen_factory, or "
969 "\"none\" for null.");
970
971 DEFINE_int32(write_fault_one_in, 0,
972 "On non-zero, enables fault injection on write");
973
974 DEFINE_uint64(user_timestamp_size, 0,
975 "Number of bytes for a user-defined timestamp. Currently, only "
976 "8-byte is supported");
977
978 DEFINE_int32(open_metadata_write_fault_one_in, 0,
979 "On non-zero, enables fault injection on file metadata write "
980 "during DB reopen.");
981
982 #ifndef ROCKSDB_LITE
983 DEFINE_string(secondary_cache_uri, "",
984 "Full URI for creating a customized secondary cache object");
985 DEFINE_int32(secondary_cache_fault_one_in, 0,
986 "On non-zero, enables fault injection in secondary cache inserts"
987 " and lookups");
988 #endif // ROCKSDB_LITE
989 DEFINE_int32(open_write_fault_one_in, 0,
990 "On non-zero, enables fault injection on file writes "
991 "during DB reopen.");
992 DEFINE_int32(open_read_fault_one_in, 0,
993 "On non-zero, enables fault injection on file reads "
994 "during DB reopen.");
995 DEFINE_int32(injest_error_severity, 1,
996 "The severity of the injested IO Error. 1 is soft error (e.g. "
997 "retryable error), 2 is fatal error, and the default is "
998 "retryable error.");
999 DEFINE_int32(prepopulate_block_cache,
1000 static_cast<int32_t>(ROCKSDB_NAMESPACE::BlockBasedTableOptions::
1001 PrepopulateBlockCache::kDisable),
1002 "Options related to cache warming (see `enum "
1003 "PrepopulateBlockCache` in table.h)");
1004
1005 DEFINE_bool(two_write_queues, false,
1006 "Set to true to enable two write queues. Default: false");
1007 #ifndef ROCKSDB_LITE
1008
1009 DEFINE_bool(use_only_the_last_commit_time_batch_for_recovery, false,
1010 "If true, the commit-time write batch will not be immediately "
1011 "inserted into the memtables. Default: false");
1012
1013 DEFINE_uint64(
1014 wp_snapshot_cache_bits, 7ull,
1015 "Number of bits to represent write-prepared transaction db's snapshot "
1016 "cache. Default: 7 (128 entries)");
1017
1018 DEFINE_uint64(wp_commit_cache_bits, 23ull,
1019 "Number of bits to represent write-prepared transaction db's "
1020 "commit cache. Default: 23 (8M entries)");
1021 #endif // !ROCKSDB_LITE
1022
1023 DEFINE_bool(adaptive_readahead, false,
1024 "Carry forward internal auto readahead size from one file to next "
1025 "file at each level during iteration");
1026 DEFINE_bool(
1027 async_io, false,
1028 "Does asynchronous prefetching when internal auto readahead is enabled");
1029
1030 DEFINE_string(wal_compression, "none",
1031 "Algorithm to use for WAL compression. none to disable.");
1032
1033 DEFINE_bool(
1034 verify_sst_unique_id_in_manifest, false,
1035 "Enable DB options `verify_sst_unique_id_in_manifest`, if true, during "
1036 "DB-open try verifying the SST unique id between MANIFEST and SST "
1037 "properties.");
1038
1039 DEFINE_int32(
1040 create_timestamped_snapshot_one_in, 0,
1041 "On non-zero, create timestamped snapshots upon transaction commits.");
1042
1043 DEFINE_bool(allow_data_in_errors,
1044 ROCKSDB_NAMESPACE::Options().allow_data_in_errors,
1045 "If true, allow logging data, e.g. key, value in LOG files.");
1046
1047 DEFINE_int32(verify_iterator_with_expected_state_one_in, 0,
1048 "If non-zero, when TestIterate() is to be called, there is a "
1049 "1/verify_iterator_with_expected_state_one_in "
1050 "chance that the iterator is verified against the expected state "
1051 "file, instead of comparing keys between two iterators.");
1052
1053 DEFINE_uint64(readahead_size, 0, "Iterator readahead size");
1054 DEFINE_uint64(initial_auto_readahead_size, 0,
1055 "Initial auto readahead size for prefetching during Iteration");
1056 DEFINE_uint64(max_auto_readahead_size, 0,
1057 "Max auto readahead size for prefetching during Iteration");
1058 DEFINE_uint64(
1059 num_file_reads_for_auto_readahead, 0,
1060 "Num of sequential reads to enable auto prefetching during Iteration");
1061
1062 DEFINE_bool(
1063 preserve_unverified_changes, false,
1064 "DB files of the current run will all be preserved in `FLAGS_db`. DB files "
1065 "from the last run will be preserved in `FLAGS_db/unverified` until the "
1066 "first verification succeeds. Expected state files from the last run will "
1067 "be preserved similarly under `FLAGS_expected_values_dir/unverified` when "
1068 "`--expected_values_dir` is nonempty.");
1069
1070 DEFINE_uint64(stats_dump_period_sec,
1071 ROCKSDB_NAMESPACE::Options().stats_dump_period_sec,
1072 "Gap between printing stats to log in seconds");
1073
1074 #endif // GFLAGS