forked from percona/percona-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ha_rocksdb.cc
13523 lines (11430 loc) · 466 KB
/
ha_rocksdb.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2012, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#define MYSQL_SERVER 1
/* The C++ file's header */
#include "./ha_rocksdb.h"
/* C++ standard header files */
#include <algorithm>
#include <inttypes.h>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
/* MySQL includes */
#include "my_stacktrace.h"
#include "my_sys.h"
#include "mysql/thread_pool_priv.h"
#include "mysys_err.h"
#include "sql/debug_sync.h"
#include "sql-common/json_dom.h"
#include "sql/mysqld.h"
#include "sql/sql_audit.h"
#include "sql/sql_lex.h"
#include "sql/sql_partition.h"
#include "sql/sql_table.h"
#include "sql/sql_thd_internal_api.h"
#include "sql/table.h"
// Both MySQL and RocksDB define the same constant. To avoid compilation errors
// till we make the fix in RocksDB, we'll temporary undefine it here.
#undef CACHE_LINE_SIZE
/* RocksDB includes */
#include "monitoring/histogram.h"
#include "rocksdb/compaction_filter.h"
#include "rocksdb/env.h"
#include "rocksdb/memory_allocator.h"
#include "rocksdb/persistent_cache.h"
#include "rocksdb/rate_limiter.h"
#include "rocksdb/slice_transform.h"
#include "rocksdb/thread_status.h"
#include "rocksdb/utilities/checkpoint.h"
#include "rocksdb/utilities/convenience.h"
#include "rocksdb/utilities/memory_util.h"
#include "rocksdb/utilities/sim_cache.h"
#include "rocksdb/utilities/write_batch_with_index.h"
#include "util/stop_watch.h"
/* MyRocks includes */
#include "./event_listener.h"
#include "./ha_rocksdb_proto.h"
#include "./ha_rockspart.h"
#include "./logger.h"
#include "./rdb_cf_manager.h"
#include "./rdb_cf_options.h"
#include "./rdb_datadic.h"
#include "./rdb_i_s.h"
#include "./rdb_index_merge.h"
#include "./rdb_mutex_wrapper.h"
#include "./rdb_psi.h"
#include "./rdb_threads.h"
// MySQL 8.0 logger service interface
static SERVICE_TYPE(registry) *reg_srv = nullptr;
SERVICE_TYPE(log_builtins) *log_bi = nullptr;
SERVICE_TYPE(log_builtins_string) *log_bs = nullptr;
namespace myrocks {
static st_global_stats global_stats;
static st_export_stats export_stats;
static st_memory_stats memory_stats;
static st_io_stall_stats io_stall_stats;
const std::string DEFAULT_CF_NAME("default");
const std::string DEFAULT_SYSTEM_CF_NAME("__system__");
const std::string PER_INDEX_CF_NAME("$per_index_cf");
static std::vector<GL_INDEX_ID> rdb_indexes_to_recalc;
/**
Updates row counters based on the table type and operation type.
*/
void ha_rocksdb::update_row_stats(const operation_type &type) {
DBUG_ASSERT(type < ROWS_MAX);
// Find if we are modifying system databases.
if (table->s && m_tbl_def->m_is_mysql_system_table)
global_stats.system_rows[type].inc();
else
global_stats.rows[type].inc();
}
void dbug_dump_database(rocksdb::DB *db);
static handler *rocksdb_create_handler(my_core::handlerton *hton,
my_core::TABLE_SHARE *table_arg,
bool partitioned,
my_core::MEM_ROOT *mem_root);
static rocksdb::CompactRangeOptions
getCompactRangeOptions(int concurrency = 0) {
rocksdb::CompactRangeOptions compact_range_options;
compact_range_options.bottommost_level_compaction =
rocksdb::BottommostLevelCompaction::kForce;
compact_range_options.exclusive_manual_compaction = false;
if (concurrency > 0) {
compact_range_options.max_subcompactions = concurrency;
}
return compact_range_options;
}
///////////////////////////////////////////////////////////
// Parameters and settings
///////////////////////////////////////////////////////////
static char *rocksdb_default_cf_options = nullptr;
static char *rocksdb_override_cf_options = nullptr;
static char *rocksdb_update_cf_options = nullptr;
///////////////////////////////////////////////////////////
// Globals
///////////////////////////////////////////////////////////
handlerton *rocksdb_hton;
rocksdb::TransactionDB *rdb = nullptr;
rocksdb::HistogramImpl *commit_latency_stats = nullptr;
static std::shared_ptr<rocksdb::Statistics> rocksdb_stats;
static std::shared_ptr<Rdb_tbl_prop_coll_factory> properties_collector_factory;
Rdb_dict_manager dict_manager;
Rdb_cf_manager cf_manager;
Rdb_ddl_manager ddl_manager;
Rdb_hton_init_state hton_init_state;
/**
MyRocks background thread control
N.B. This is besides RocksDB's own background threads
(@see rocksdb::CancelAllBackgroundWork())
*/
static Rdb_background_thread rdb_bg_thread;
static Rdb_manual_compaction_thread rdb_mc_thread;
// List of table names (using regex) that are exceptions to the strict
// collation check requirement.
std::unique_ptr<std::regex> rdb_collation_exceptions;
static const char *rdb_get_error_messages(int error);
static void rocksdb_flush_all_memtables() {
const Rdb_cf_manager &cf_manager = rdb_get_cf_manager();
for (const auto &cf_handle : cf_manager.get_all_cf()) {
rdb->Flush(rocksdb::FlushOptions(), cf_handle);
}
}
///////////////////////////////////////////////////////////
// Hash map: table name => open table handler
///////////////////////////////////////////////////////////
namespace // anonymous namespace = not visible outside this source file
{
struct Rdb_open_tables_map {
/* Hash table used to track the handlers of open tables */
std::unordered_map<std::string, Rdb_table_handler *> m_hash;
/* The mutex used to protect the hash table */
mutable mysql_mutex_t m_mutex;
Rdb_table_handler *get_table_handler(const char *const table_name);
void release_table_handler(Rdb_table_handler *const table_handler);
std::vector<std::string> get_table_names(void) const;
};
} // anonymous namespace
static Rdb_open_tables_map rdb_open_tables;
static std::string rdb_normalize_dir(std::string dir) {
while (dir.size() > 0 && dir.back() == '/') {
dir.resize(dir.size() - 1);
}
return dir;
}
static int rocksdb_create_checkpoint(const char *checkpoint_dir_raw) {
DBUG_ASSERT(checkpoint_dir_raw);
const auto checkpoint_dir = rdb_normalize_dir(checkpoint_dir_raw);
LogPluginErrMsg(INFORMATION_LEVEL, 0,
"creating checkpoint in directory: %s\n",
checkpoint_dir.c_str());
rocksdb::Checkpoint *checkpoint;
auto status = rocksdb::Checkpoint::Create(rdb, &checkpoint);
if (status.ok()) {
status = checkpoint->CreateCheckpoint(checkpoint_dir.c_str());
delete checkpoint;
if (status.ok()) {
LogPluginErrMsg(INFORMATION_LEVEL, 0,
"created checkpoint in directory: %s\n",
checkpoint_dir.c_str());
return HA_EXIT_SUCCESS;
} else {
my_error(ER_GET_ERRMSG, MYF(0), status.code(), status.ToString().c_str(),
rocksdb_hton_name);
}
} else {
my_error(ER_GET_ERRMSG, MYF(0), status.code(), status.ToString().c_str(),
rocksdb_hton_name);
}
return HA_EXIT_FAILURE;
}
static int rocksdb_remove_checkpoint(const char *checkpoint_dir_raw) {
const auto checkpoint_dir = rdb_normalize_dir(checkpoint_dir_raw);
LogPluginErrMsg(INFORMATION_LEVEL, 0,
"deleting temporary checkpoint in directory : %s\n",
checkpoint_dir.c_str());
const auto status = rocksdb::DestroyDB(checkpoint_dir, rocksdb::Options());
if (status.ok()) {
return HA_EXIT_SUCCESS;
}
my_error(ER_GET_ERRMSG, MYF(0), status.code(), status.ToString().c_str(),
rocksdb_hton_name);
return HA_EXIT_FAILURE;
}
static int rocksdb_create_checkpoint_validate(
THD *const thd MY_ATTRIBUTE((__unused__)),
struct SYS_VAR *const var MY_ATTRIBUTE((__unused__)),
void *const save MY_ATTRIBUTE((__unused__)),
struct st_mysql_value *const value) {
char buf[FN_REFLEN];
int len = sizeof(buf);
const char *const checkpoint_dir_raw = value->val_str(value, buf, &len);
if (checkpoint_dir_raw) {
return rocksdb_create_checkpoint(checkpoint_dir_raw);
}
return HA_EXIT_FAILURE;
}
/* This method is needed to indicate that the
ROCKSDB_CREATE_CHECKPOINT command is not read-only */
static void rocksdb_create_checkpoint_update(THD *const thd,
struct SYS_VAR *const var,
void *const var_ptr,
const void *const save) {}
static int rocksdb_create_temporary_checkpoint_validate(
THD *const thd, struct SYS_VAR *const var, void *const save,
struct st_mysql_value *const value);
static void rocksdb_disable_file_deletions_update(
my_core::THD *const thd, my_core::SYS_VAR *const /* unused */,
void *const var_ptr, const void *const save);
static void rocksdb_force_flush_memtable_now_stub(THD *const thd,
struct SYS_VAR *const var,
void *const var_ptr,
const void *const save) {}
static int
rocksdb_force_flush_memtable_now(THD *const thd, struct SYS_VAR *const var,
void *const var_ptr,
struct st_mysql_value *const value) {
LogPluginErrMsg(INFORMATION_LEVEL, 0, "Manual memtable flush.");
rocksdb_flush_all_memtables();
return HA_EXIT_SUCCESS;
}
static void rocksdb_force_flush_memtable_and_lzero_now_stub(
THD *const thd, struct SYS_VAR *const var, void *const var_ptr,
const void *const save) {}
static int rocksdb_force_flush_memtable_and_lzero_now(
THD *const thd, struct SYS_VAR *const var, void *const var_ptr,
struct st_mysql_value *const value) {
LogPluginErrMsg(INFORMATION_LEVEL, 0, "Manual memtable and L0 flush.");
rocksdb_flush_all_memtables();
const Rdb_cf_manager &cf_manager = rdb_get_cf_manager();
rocksdb::CompactionOptions c_options = rocksdb::CompactionOptions();
rocksdb::ColumnFamilyMetaData metadata;
rocksdb::ColumnFamilyDescriptor cf_descr;
static constexpr int max_attempts = 3;
int i, num_errors = 0;
for (const auto &cf_handle : cf_manager.get_all_cf()) {
for (i = 0; i < max_attempts; i++) {
rdb->GetColumnFamilyMetaData(cf_handle, &metadata);
cf_handle->GetDescriptor(&cf_descr);
c_options.output_file_size_limit = cf_descr.options.target_file_size_base;
DBUG_ASSERT(metadata.levels[0].level == 0);
std::vector<std::string> file_names;
for (const auto &file : metadata.levels[0].files) {
file_names.emplace_back(file.db_path + file.name);
}
if (file_names.empty()) {
break;
}
rocksdb::Status s;
s = rdb->CompactFiles(c_options, cf_handle, file_names, 1);
// Due to a race, it's possible for CompactFiles to collide
// with auto compaction, causing an error to return
// regarding file not found. In that case, retry.
if (s.IsInvalidArgument()) {
continue;
}
if (!s.ok() && !s.IsAborted()) {
rdb_handle_io_error(s, RDB_IO_ERROR_GENERAL);
return HA_EXIT_FAILURE;
}
break;
}
if (i == max_attempts) {
num_errors++;
}
}
return num_errors == 0 ? HA_EXIT_SUCCESS : HA_EXIT_FAILURE;
}
static void rocksdb_drop_index_wakeup_thread(
my_core::THD *const thd MY_ATTRIBUTE((__unused__)),
struct SYS_VAR *const var MY_ATTRIBUTE((__unused__)),
void *const var_ptr MY_ATTRIBUTE((__unused__)), const void *const save);
static bool rocksdb_pause_background_work = false;
static mysql_mutex_t rdb_sysvars_mutex;
static mysql_mutex_t rdb_block_cache_resize_mutex;
static void rocksdb_set_pause_background_work(
my_core::THD *const thd MY_ATTRIBUTE((__unused__)),
struct SYS_VAR *const var MY_ATTRIBUTE((__unused__)),
void *const var_ptr MY_ATTRIBUTE((__unused__)), const void *const save) {
RDB_MUTEX_LOCK_CHECK(rdb_sysvars_mutex);
const bool pause_requested = *static_cast<const bool *>(save);
if (rocksdb_pause_background_work != pause_requested) {
if (pause_requested) {
rdb->PauseBackgroundWork();
} else {
rdb->ContinueBackgroundWork();
}
rocksdb_pause_background_work = pause_requested;
}
RDB_MUTEX_UNLOCK_CHECK(rdb_sysvars_mutex);
}
static void rocksdb_set_compaction_options(THD *thd, struct SYS_VAR *var,
void *var_ptr, const void *save);
static void rocksdb_set_table_stats_sampling_pct(THD *thd, struct SYS_VAR *var,
void *var_ptr,
const void *save);
static void rocksdb_set_rate_limiter_bytes_per_sec(THD *thd,
struct SYS_VAR *var,
void *var_ptr,
const void *save);
static void rocksdb_set_sst_mgr_rate_bytes_per_sec(THD *thd,
struct SYS_VAR *var,
void *var_ptr,
const void *save);
static void rocksdb_set_delayed_write_rate(THD *thd, struct SYS_VAR *var,
void *var_ptr, const void *save);
static void rocksdb_set_max_latest_deadlocks(THD *thd, struct SYS_VAR *var,
void *var_ptr, const void *save);
static void rdb_set_collation_exception_list(const char *exception_list);
static void rocksdb_set_collation_exception_list(THD *thd, struct SYS_VAR *var,
void *var_ptr,
const void *save);
static int rocksdb_validate_update_cf_options(THD *thd, struct SYS_VAR *var,
void *save,
st_mysql_value *value);
static void rocksdb_set_update_cf_options(THD *thd, struct SYS_VAR *var,
void *var_ptr, const void *save);
static int
rocksdb_check_bulk_load(THD *const thd,
struct SYS_VAR *var MY_ATTRIBUTE((__unused__)),
void *save, struct st_mysql_value *value);
static int rocksdb_check_bulk_load_allow_unsorted(
THD *const thd, struct SYS_VAR *var MY_ATTRIBUTE((__unused__)), void *save,
struct st_mysql_value *value);
static void rocksdb_set_max_background_jobs(THD *thd, struct SYS_VAR *const var,
void *const var_ptr,
const void *const save);
static void rocksdb_set_bytes_per_sync(THD *thd, struct SYS_VAR *const var,
void *const var_ptr,
const void *const save);
static void rocksdb_set_wal_bytes_per_sync(THD *thd, struct SYS_VAR *const var,
void *const var_ptr,
const void *const save);
static int rocksdb_validate_set_block_cache_size(THD *thd,
struct SYS_VAR *const var,
void *var_ptr,
struct st_mysql_value *value);
//////////////////////////////////////////////////////////////////////////////
// Options definitions
//////////////////////////////////////////////////////////////////////////////
static const constexpr ulong RDB_MAX_LOCK_WAIT_SECONDS = 1024 * 1024 * 1024;
static const constexpr ulong RDB_MAX_ROW_LOCKS = 1024 * 1024 * 1024;
static const constexpr ulong RDB_DEFAULT_ROW_LOCKS = 1024 * 1024;
static const constexpr ulong RDB_DEFAULT_BULK_LOAD_SIZE = 1000;
static const constexpr int RDB_DEFAULT_MAX_BACKGROUND_JOBS = 2;
static const constexpr ulong RDB_DEFAULT_BLOCK_SIZE = 0x4000; // 16K
static const constexpr ulong RDB_DEFAULT_MAX_TOTAL_WAL_SIZE =
0x80000000; // 2GB
static const constexpr ulong RDB_DEFAULT_TABLE_CACHE_NUMSHARDBITS = 6;
static const constexpr ulong RDB_MAX_BULK_LOAD_SIZE = 1024 * 1024 * 1024;
static const constexpr size_t RDB_DEFAULT_MERGE_BUF_SIZE = 64 * 1024 * 1024;
static const constexpr size_t RDB_MIN_MERGE_BUF_SIZE = 100;
static const constexpr size_t RDB_DEFAULT_MERGE_COMBINE_READ_SIZE =
1024 * 1024 * 1024;
static const constexpr size_t RDB_MIN_MERGE_COMBINE_READ_SIZE = 100;
static const constexpr size_t RDB_DEFAULT_MERGE_TMP_FILE_REMOVAL_DELAY = 0;
static const constexpr size_t RDB_MIN_MERGE_TMP_FILE_REMOVAL_DELAY = 0;
static const constexpr int64 RDB_DEFAULT_BLOCK_CACHE_SIZE = 512 * 1024 * 1024;
static const constexpr int64 RDB_MIN_BLOCK_CACHE_SIZE = 1024;
static const constexpr int RDB_MAX_CHECKSUMS_PCT = 100;
static const constexpr uint32_t
RDB_DEFAULT_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = 60 * 1000 * 1000;
static const constexpr ulong RDB_DEADLOCK_DETECT_DEPTH = 50;
static long long rocksdb_block_cache_size = RDB_DEFAULT_BLOCK_CACHE_SIZE;
static long long rocksdb_sim_cache_size = 0;
static double rocksdb_cache_high_pri_pool_ratio = 0.0;
static bool rocksdb_cache_dump = false;
/* Use unsigned long long instead of uint64_t because of MySQL compatibility */
static unsigned long long // NOLINT(runtime/int)
rocksdb_rate_limiter_bytes_per_sec = 0;
static unsigned long long // NOLINT(runtime/int)
rocksdb_sst_mgr_rate_bytes_per_sec = DEFAULT_SST_MGR_RATE_BYTES_PER_SEC;
static unsigned long long rocksdb_delayed_write_rate;
static uint32_t rocksdb_max_latest_deadlocks = RDB_DEADLOCK_DETECT_DEPTH;
static unsigned long // NOLINT(runtime/int)
rocksdb_persistent_cache_size_mb = 0;
static uint64_t rocksdb_info_log_level = rocksdb::InfoLogLevel::ERROR_LEVEL;
static char *rocksdb_wal_dir = nullptr;
static char *rocksdb_persistent_cache_path = nullptr;
static uint64_t rocksdb_index_type =
rocksdb::BlockBasedTableOptions::kBinarySearch;
static uint32_t rocksdb_flush_log_at_trx_commit = 1;
static uint32_t rocksdb_debug_optimizer_n_rows = 0;
static bool rocksdb_force_compute_memtable_stats = true;
static uint32_t rocksdb_force_compute_memtable_stats_cachetime =
RDB_DEFAULT_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
static bool rocksdb_debug_optimizer_no_zero_cardinality = true;
static uint32_t rocksdb_wal_recovery_mode =
static_cast<uint32_t>(rocksdb::WALRecoveryMode::kAbsoluteConsistency);
static uint32_t rocksdb_access_hint_on_compaction_start =
rocksdb::Options::AccessHint::NORMAL;
static char *rocksdb_compact_cf_name = nullptr;
static char *rocksdb_checkpoint_name = nullptr;
static bool rocksdb_signal_drop_index_thread = false;
static bool rocksdb_strict_collation_check = true;
static bool rocksdb_ignore_unknown_options = true;
static char *rocksdb_strict_collation_exceptions = nullptr;
static bool rocksdb_collect_sst_properties = true;
static bool rocksdb_force_flush_memtable_now_var = false;
static bool rocksdb_force_flush_memtable_and_lzero_now_var = false;
static bool rocksdb_enable_ttl = true;
static bool rocksdb_enable_ttl_read_filtering = true;
static int rocksdb_debug_ttl_rec_ts = 0;
static int rocksdb_debug_ttl_snapshot_ts = 0;
static int rocksdb_debug_ttl_read_filter_ts = 0;
static bool rocksdb_debug_ttl_ignore_pk = false;
static bool rocksdb_reset_stats = false;
static uint32_t rocksdb_seconds_between_stat_computes = 3600;
static long long rocksdb_compaction_sequential_deletes = 0l;
static long long rocksdb_compaction_sequential_deletes_window = 0l;
static long long rocksdb_compaction_sequential_deletes_file_size = 0l;
#if defined(ROCKSDB_INCLUDE_VALIDATE_TABLES) && ROCKSDB_INCLUDE_VALIDATE_TABLES
static uint32_t rocksdb_validate_tables = 1;
#endif // defined(ROCKSDB_INCLUDE_VALIDATE_TABLES) &&
// ROCKSDB_INCLUDE_VALIDATE_TABLES
static char *rocksdb_datadir = nullptr;
static uint32_t rocksdb_table_stats_sampling_pct =
RDB_DEFAULT_TBL_STATS_SAMPLE_PCT;
static bool rocksdb_enable_bulk_load_api = true;
static bool rpl_skip_tx_api_var = false;
static bool rocksdb_print_snapshot_conflict_queries = false;
static bool rocksdb_large_prefix = true;
static bool rocksdb_allow_to_start_after_corruption = false;
static uint64_t rocksdb_write_policy =
rocksdb::TxnDBWritePolicy::WRITE_COMMITTED;
static bool rocksdb_error_on_suboptimal_collation = false;
static uint32_t rocksdb_stats_recalc_rate = 0;
static bool rocksdb_no_create_column_family = false;
static uint32_t rocksdb_debug_manual_compaction_delay = 0;
static uint32_t rocksdb_max_manual_compactions = 0;
static bool rocksdb_rollback_on_timeout = false;
std::atomic<uint64_t> rocksdb_row_lock_deadlocks(0);
std::atomic<uint64_t> rocksdb_row_lock_wait_timeouts(0);
std::atomic<uint64_t> rocksdb_snapshot_conflict_errors(0);
std::atomic<uint64_t> rocksdb_wal_group_syncs(0);
std::atomic<uint64_t> rocksdb_manual_compactions_processed(0);
std::atomic<uint64_t> rocksdb_manual_compactions_running(0);
static std::unique_ptr<rocksdb::DBOptions> rdb_init_rocksdb_db_options(void) {
auto o = std::unique_ptr<rocksdb::DBOptions>(new rocksdb::DBOptions());
o->create_if_missing = true;
o->listeners.push_back(std::make_shared<Rdb_event_listener>(&ddl_manager));
o->info_log_level = rocksdb::InfoLogLevel::INFO_LEVEL;
o->max_background_jobs = RDB_DEFAULT_MAX_BACKGROUND_JOBS;
o->max_subcompactions = DEFAULT_SUBCOMPACTIONS;
o->max_open_files = -2; // auto-tune to 50% open_files_limit
o->max_total_wal_size = RDB_DEFAULT_MAX_TOTAL_WAL_SIZE;
o->table_cache_numshardbits = RDB_DEFAULT_TABLE_CACHE_NUMSHARDBITS;
o->two_write_queues = true;
o->manual_wal_flush = true;
return o;
}
static std::unique_ptr<rocksdb::BlockBasedTableOptions>
rdb_init_rocksdb_tbl_options(void) {
auto o = std::unique_ptr<rocksdb::BlockBasedTableOptions>(
new rocksdb::BlockBasedTableOptions());
o->block_size = RDB_DEFAULT_BLOCK_SIZE;
return o;
}
/* DBOptions contains Statistics and needs to be destructed last */
static std::unique_ptr<rocksdb::BlockBasedTableOptions> rocksdb_tbl_options =
rdb_init_rocksdb_tbl_options();
static std::unique_ptr<rocksdb::DBOptions> rocksdb_db_options =
rdb_init_rocksdb_db_options();
static std::shared_ptr<rocksdb::RateLimiter> rocksdb_rate_limiter;
/* This enum needs to be kept up to date with rocksdb::TxnDBWritePolicy */
static const char *write_policy_names[] = {"write_committed", "write_prepared",
"write_unprepared", NullS};
static TYPELIB write_policy_typelib = {array_elements(write_policy_names) - 1,
"write_policy_typelib",
write_policy_names, nullptr};
/* This enum needs to be kept up to date with rocksdb::InfoLogLevel */
static const char *info_log_level_names[] = {"debug_level", "info_level",
"warn_level", "error_level",
"fatal_level", NullS};
static TYPELIB info_log_level_typelib = {
array_elements(info_log_level_names) - 1, "info_log_level_typelib",
info_log_level_names, nullptr};
static void rocksdb_set_rocksdb_info_log_level(THD *const thd,
struct SYS_VAR *const var,
void *const var_ptr,
const void *const save) {
DBUG_ASSERT(save != nullptr);
RDB_MUTEX_LOCK_CHECK(rdb_sysvars_mutex);
rocksdb_info_log_level = *static_cast<const uint64_t *>(save);
rocksdb_db_options->info_log->SetInfoLogLevel(
static_cast<rocksdb::InfoLogLevel>(rocksdb_info_log_level));
RDB_MUTEX_UNLOCK_CHECK(rdb_sysvars_mutex);
}
static void rocksdb_set_reset_stats(my_core::THD *const /* unused */,
my_core::SYS_VAR *const /* unused */,
void *const var_ptr,
const void *const save) {
DBUG_ASSERT(save != nullptr);
DBUG_ASSERT(rdb != nullptr);
DBUG_ASSERT(rocksdb_stats != nullptr);
RDB_MUTEX_LOCK_CHECK(rdb_sysvars_mutex);
*static_cast<bool *>(var_ptr) = *static_cast<const bool *>(save);
if (rocksdb_reset_stats) {
rocksdb::Status s = rdb->ResetStats();
// RocksDB will always return success. Let's document this assumption here
// as well so that we'll get immediately notified when contract changes.
DBUG_ASSERT(s == rocksdb::Status::OK());
s = rocksdb_stats->Reset();
DBUG_ASSERT(s == rocksdb::Status::OK());
}
RDB_MUTEX_UNLOCK_CHECK(rdb_sysvars_mutex);
}
enum rocksdb_flush_log_at_trx_commit_type : unsigned int {
FLUSH_LOG_NEVER = 0,
FLUSH_LOG_SYNC,
FLUSH_LOG_BACKGROUND,
FLUSH_LOG_MAX /* must be last */
};
static int rocksdb_validate_flush_log_at_trx_commit(
THD *const thd,
struct SYS_VAR *const var, /* in: pointer to system variable */
void *var_ptr, /* out: immediate result for update function */
struct st_mysql_value *const value /* in: incoming value */) {
long long new_value;
/* value is NULL */
if (value->val_int(value, &new_value)) {
return HA_EXIT_FAILURE;
}
if (rocksdb_db_options->allow_mmap_writes && new_value != FLUSH_LOG_NEVER) {
return HA_EXIT_FAILURE;
}
*static_cast<uint32_t *>(var_ptr) = static_cast<uint32_t>(new_value);
return HA_EXIT_SUCCESS;
}
static void rocksdb_compact_column_family_stub(THD *const thd,
struct SYS_VAR *const var,
void *const var_ptr,
const void *const save) {}
static int rocksdb_compact_column_family(THD *const thd,
struct SYS_VAR *const var,
void *const var_ptr,
struct st_mysql_value *const value);
static const char *index_type_names[] = {"kBinarySearch", "kHashSearch", NullS};
static TYPELIB index_type_typelib = {array_elements(index_type_names) - 1,
"index_type_typelib", index_type_names,
nullptr};
// TODO: 0 means don't wait at all, and we don't support it yet?
static MYSQL_THDVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG,
"Number of seconds to wait for lock", nullptr,
nullptr, /*default*/ 1, /*min*/ 1,
/*max*/ RDB_MAX_LOCK_WAIT_SECONDS, 0);
static MYSQL_THDVAR_BOOL(deadlock_detect, PLUGIN_VAR_RQCMDARG,
"Enables deadlock detection", nullptr, nullptr, false);
static MYSQL_THDVAR_ULONG(deadlock_detect_depth, PLUGIN_VAR_RQCMDARG,
"Number of transactions deadlock detection will "
"traverse through before assuming deadlock",
nullptr, nullptr,
/*default*/ RDB_DEADLOCK_DETECT_DEPTH,
/*min*/ 2,
/*max*/ ULONG_MAX, 0);
static MYSQL_THDVAR_BOOL(
commit_time_batch_for_recovery, PLUGIN_VAR_RQCMDARG,
"TransactionOptions::commit_time_batch_for_recovery for RocksDB", nullptr,
nullptr, false);
static MYSQL_THDVAR_BOOL(
trace_sst_api, PLUGIN_VAR_RQCMDARG,
"Generate trace output in the log for each call to the SstFileWriter",
nullptr, nullptr, false);
static MYSQL_THDVAR_BOOL(
bulk_load, PLUGIN_VAR_RQCMDARG,
"Use bulk-load mode for inserts. This disables "
"unique_checks and enables rocksdb_commit_in_the_middle.",
rocksdb_check_bulk_load, nullptr, false);
static MYSQL_THDVAR_BOOL(bulk_load_allow_sk, PLUGIN_VAR_RQCMDARG,
"Allow bulk loading of sk keys during bulk-load. "
"Can be changed only when bulk load is disabled.",
/* Intentionally reuse unsorted's check function */
rocksdb_check_bulk_load_allow_unsorted, nullptr,
false);
static MYSQL_THDVAR_BOOL(bulk_load_allow_unsorted, PLUGIN_VAR_RQCMDARG,
"Allow unsorted input during bulk-load. "
"Can be changed only when bulk load is disabled.",
rocksdb_check_bulk_load_allow_unsorted, nullptr,
false);
static MYSQL_SYSVAR_BOOL(enable_bulk_load_api, rocksdb_enable_bulk_load_api,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Enables using SstFileWriter for bulk loading",
nullptr, nullptr, rocksdb_enable_bulk_load_api);
static MYSQL_THDVAR_STR(tmpdir, PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC,
"Directory for temporary files during DDL operations.",
nullptr, nullptr, "");
static MYSQL_THDVAR_BOOL(
commit_in_the_middle, PLUGIN_VAR_RQCMDARG,
"Commit rows implicitly every rocksdb_bulk_load_size, on bulk load/insert, "
"update and delete",
nullptr, nullptr, false);
#if defined(ROCKSDB_INCLUDE_RFR) && ROCKSDB_INCLUDE_RFR
#define DEFAULT_READ_FREE_RPL_TABLES ""
static MYSQL_THDVAR_STR(
read_free_rpl_tables, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"Regex that describes set of tables that will use read-free replication "
"on the slave (i.e. not lookup a row during replication)",
nullptr, nullptr, DEFAULT_READ_FREE_RPL_TABLES);
#endif // defined(ROCKSDB_INCLUDE_RFR) && ROCKSDB_INCLUDE_RFR
static MYSQL_SYSVAR_BOOL(
rpl_skip_tx_api, rpl_skip_tx_api_var, PLUGIN_VAR_RQCMDARG,
"Use write batches for replication thread instead of tx api", nullptr,
nullptr, false);
static MYSQL_THDVAR_BOOL(skip_bloom_filter_on_read, PLUGIN_VAR_RQCMDARG,
"Skip using bloom filter for reads", nullptr, nullptr,
false);
static MYSQL_THDVAR_ULONG(max_row_locks, PLUGIN_VAR_RQCMDARG,
"Maximum number of locks a transaction can have",
nullptr, nullptr,
/*default*/ RDB_DEFAULT_ROW_LOCKS,
/*min*/ 1,
/*max*/ RDB_MAX_ROW_LOCKS, 0);
static MYSQL_THDVAR_ULONGLONG(
write_batch_max_bytes, PLUGIN_VAR_RQCMDARG,
"Maximum size of write batch in bytes. 0 means no limit.", nullptr, nullptr,
/* default */ 0, /* min */ 0, /* max */ SIZE_T_MAX, 1);
static MYSQL_THDVAR_BOOL(
lock_scanned_rows, PLUGIN_VAR_RQCMDARG,
"Take and hold locks on rows that are scanned but not updated", nullptr,
nullptr, false);
static MYSQL_THDVAR_ULONG(bulk_load_size, PLUGIN_VAR_RQCMDARG,
"Max #records in a batch for bulk-load mode", nullptr,
nullptr,
/*default*/ RDB_DEFAULT_BULK_LOAD_SIZE,
/*min*/ 1,
/*max*/ RDB_MAX_BULK_LOAD_SIZE, 0);
static MYSQL_THDVAR_ULONGLONG(
merge_buf_size, PLUGIN_VAR_RQCMDARG,
"Size to allocate for merge sort buffers written out to disk "
"during inplace index creation.",
nullptr, nullptr,
/* default (64MB) */ RDB_DEFAULT_MERGE_BUF_SIZE,
/* min (100B) */ RDB_MIN_MERGE_BUF_SIZE,
/* max */ SIZE_T_MAX, 1);
static MYSQL_THDVAR_ULONGLONG(
merge_combine_read_size, PLUGIN_VAR_RQCMDARG,
"Size that we have to work with during combine (reading from disk) phase "
"of "
"external sort during fast index creation.",
nullptr, nullptr,
/* default (1GB) */ RDB_DEFAULT_MERGE_COMBINE_READ_SIZE,
/* min (100B) */ RDB_MIN_MERGE_COMBINE_READ_SIZE,
/* max */ SIZE_T_MAX, 1);
static MYSQL_THDVAR_ULONGLONG(
merge_tmp_file_removal_delay_ms, PLUGIN_VAR_RQCMDARG,
"Fast index creation creates a large tmp file on disk during index "
"creation. Removing this large file all at once when index creation is "
"complete can cause trim stalls on Flash. This variable specifies a "
"duration to sleep (in milliseconds) between calling chsize() to truncate "
"the file in chunks. The chunk size is the same as merge_buf_size.",
nullptr, nullptr,
/* default (0ms) */ RDB_DEFAULT_MERGE_TMP_FILE_REMOVAL_DELAY,
/* min (0ms) */ RDB_MIN_MERGE_TMP_FILE_REMOVAL_DELAY,
/* max */ SIZE_T_MAX, 1);
static MYSQL_THDVAR_INT(
manual_compaction_threads, PLUGIN_VAR_RQCMDARG,
"How many rocksdb threads to run for manual compactions", nullptr, nullptr,
/* default rocksdb.dboption max_subcompactions */ 0,
/* min */ 0, /* max */ 128, 0);
static MYSQL_SYSVAR_BOOL(
create_if_missing,
*static_cast<bool *>(&rocksdb_db_options->create_if_missing),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::create_if_missing for RocksDB", nullptr, nullptr,
rocksdb_db_options->create_if_missing);
static void concurrent_prepare_update(THD *thd, SYS_VAR *var, void *var_ptr,
const void *save) {
push_warning(thd, Sql_condition::SL_WARNING, HA_ERR_WRONG_COMMAND,
"Using rocksdb_concurrent_prepare is deprecated and the "
"parameter may be removed in future releases.");
}
static MYSQL_SYSVAR_BOOL(
concurrent_prepare,
*static_cast<bool *>(&rocksdb_db_options->two_write_queues),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DEPRECATED, use rocksdb_two_write_queries instead.", nullptr,
concurrent_prepare_update, rocksdb_db_options->two_write_queues);
static MYSQL_SYSVAR_BOOL(
two_write_queues,
*static_cast<bool *>(&rocksdb_db_options->two_write_queues),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::two_write_queues for RocksDB", nullptr, nullptr,
rocksdb_db_options->two_write_queues);
static MYSQL_SYSVAR_BOOL(
manual_wal_flush,
*static_cast<bool *>(&rocksdb_db_options->manual_wal_flush),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::manual_wal_flush for RocksDB", nullptr, nullptr,
rocksdb_db_options->manual_wal_flush);
static MYSQL_SYSVAR_ENUM(write_policy, rocksdb_write_policy,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::write_policy for RocksDB", nullptr,
nullptr, rocksdb::TxnDBWritePolicy::WRITE_COMMITTED,
&write_policy_typelib);
static MYSQL_SYSVAR_BOOL(
create_missing_column_families,
*static_cast<bool *>(&rocksdb_db_options->create_missing_column_families),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::create_missing_column_families for RocksDB", nullptr, nullptr,
rocksdb_db_options->create_missing_column_families);
static MYSQL_SYSVAR_BOOL(
error_if_exists, *static_cast<bool *>(&rocksdb_db_options->error_if_exists),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::error_if_exists for RocksDB", nullptr, nullptr,
rocksdb_db_options->error_if_exists);
static MYSQL_SYSVAR_BOOL(
paranoid_checks, *static_cast<bool *>(&rocksdb_db_options->paranoid_checks),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::paranoid_checks for RocksDB", nullptr, nullptr,
rocksdb_db_options->paranoid_checks);
static MYSQL_SYSVAR_ULONGLONG(
rate_limiter_bytes_per_sec, rocksdb_rate_limiter_bytes_per_sec,
PLUGIN_VAR_RQCMDARG, "DBOptions::rate_limiter bytes_per_sec for RocksDB",
nullptr, rocksdb_set_rate_limiter_bytes_per_sec, /* default */ 0L,
/* min */ 0L, /* max */ MAX_RATE_LIMITER_BYTES_PER_SEC, 0);
static MYSQL_SYSVAR_ULONGLONG(
sst_mgr_rate_bytes_per_sec, rocksdb_sst_mgr_rate_bytes_per_sec,
PLUGIN_VAR_RQCMDARG,
"DBOptions::sst_file_manager rate_bytes_per_sec for RocksDB", nullptr,
rocksdb_set_sst_mgr_rate_bytes_per_sec,
/* default */ DEFAULT_SST_MGR_RATE_BYTES_PER_SEC,
/* min */ 0L, /* max */ UINT64_MAX, 0);
static MYSQL_SYSVAR_ULONGLONG(delayed_write_rate, rocksdb_delayed_write_rate,
PLUGIN_VAR_RQCMDARG,
"DBOptions::delayed_write_rate", nullptr,
rocksdb_set_delayed_write_rate,
rocksdb_db_options->delayed_write_rate, 0,
UINT64_MAX, 0);
static MYSQL_SYSVAR_UINT(max_latest_deadlocks, rocksdb_max_latest_deadlocks,
PLUGIN_VAR_RQCMDARG,
"Maximum number of recent "
"deadlocks to store",
nullptr, rocksdb_set_max_latest_deadlocks,
rocksdb::kInitialMaxDeadlocks, 0, UINT32_MAX, 0);
static MYSQL_SYSVAR_ENUM(
info_log_level, rocksdb_info_log_level, PLUGIN_VAR_RQCMDARG,
"Filter level for info logs to be written mysqld error log. "
"Valid values include 'debug_level', 'info_level', 'warn_level'"
"'error_level' and 'fatal_level'.",
nullptr, rocksdb_set_rocksdb_info_log_level,
rocksdb::InfoLogLevel::ERROR_LEVEL, &info_log_level_typelib);
static MYSQL_THDVAR_INT(
perf_context_level, PLUGIN_VAR_RQCMDARG,
"Perf Context Level for rocksdb internal timer stat collection", nullptr,
nullptr,
/* default */ rocksdb::PerfLevel::kUninitialized,
/* min */ rocksdb::PerfLevel::kUninitialized,
/* max */ rocksdb::PerfLevel::kOutOfBounds - 1, 0);
static MYSQL_SYSVAR_UINT(
wal_recovery_mode, rocksdb_wal_recovery_mode, PLUGIN_VAR_RQCMDARG,
"DBOptions::wal_recovery_mode for RocksDB. Default is kAbsoluteConsistency",
nullptr, nullptr,
/* default */ (uint)rocksdb::WALRecoveryMode::kAbsoluteConsistency,
/* min */ (uint)rocksdb::WALRecoveryMode::kTolerateCorruptedTailRecords,
/* max */ (uint)rocksdb::WALRecoveryMode::kSkipAnyCorruptedRecords, 0);
static MYSQL_SYSVAR_ULONG(compaction_readahead_size,
rocksdb_db_options->compaction_readahead_size,
PLUGIN_VAR_RQCMDARG,
"DBOptions::compaction_readahead_size for RocksDB",
nullptr, nullptr,
rocksdb_db_options->compaction_readahead_size,
/* min */ 0L, /* max */ ULONG_MAX, 0);
static MYSQL_SYSVAR_BOOL(
new_table_reader_for_compaction_inputs,
*static_cast<bool *>(
&rocksdb_db_options->new_table_reader_for_compaction_inputs),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::new_table_reader_for_compaction_inputs for RocksDB", nullptr,
nullptr, rocksdb_db_options->new_table_reader_for_compaction_inputs);
static MYSQL_SYSVAR_UINT(
access_hint_on_compaction_start, rocksdb_access_hint_on_compaction_start,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::access_hint_on_compaction_start for RocksDB", nullptr, nullptr,
/* default */ (uint)rocksdb::Options::AccessHint::NORMAL,
/* min */ (uint)rocksdb::Options::AccessHint::NONE,
/* max */ (uint)rocksdb::Options::AccessHint::WILLNEED, 0);
static MYSQL_SYSVAR_BOOL(
allow_concurrent_memtable_write,
*static_cast<bool *>(&rocksdb_db_options->allow_concurrent_memtable_write),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::allow_concurrent_memtable_write for RocksDB", nullptr, nullptr,
false);
static MYSQL_SYSVAR_BOOL(
enable_write_thread_adaptive_yield,
*static_cast<bool *>(
&rocksdb_db_options->enable_write_thread_adaptive_yield),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::enable_write_thread_adaptive_yield for RocksDB", nullptr,
nullptr, false);
static MYSQL_SYSVAR_INT(max_open_files, rocksdb_db_options->max_open_files,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::max_open_files for RocksDB", nullptr,
nullptr, rocksdb_db_options->max_open_files,
/* min */ -2, /* max */ INT_MAX, 0);
static MYSQL_SYSVAR_ULONG(max_total_wal_size,
rocksdb_db_options->max_total_wal_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::max_total_wal_size for RocksDB", nullptr,
nullptr, rocksdb_db_options->max_total_wal_size,
/* min */ 0L, /* max */ LONG_MAX, 0);
static MYSQL_SYSVAR_BOOL(use_fsync,
*static_cast<bool *>(&rocksdb_db_options->use_fsync),
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::use_fsync for RocksDB", nullptr, nullptr,
rocksdb_db_options->use_fsync);
static MYSQL_SYSVAR_STR(wal_dir, rocksdb_wal_dir,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"DBOptions::wal_dir for RocksDB", nullptr, nullptr,
rocksdb_db_options->wal_dir.c_str());
static MYSQL_SYSVAR_STR(
persistent_cache_path, rocksdb_persistent_cache_path,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Path for BlockBasedTableOptions::persistent_cache for RocksDB", nullptr,
nullptr, "");
static MYSQL_SYSVAR_ULONG(
persistent_cache_size_mb, rocksdb_persistent_cache_size_mb,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Size of cache in MB for BlockBasedTableOptions::persistent_cache "
"for RocksDB",
nullptr, nullptr, rocksdb_persistent_cache_size_mb,
/* min */ 0L, /* max */ ULONG_MAX, 0);
static MYSQL_SYSVAR_ULONG(
delete_obsolete_files_period_micros,
rocksdb_db_options->delete_obsolete_files_period_micros,