-
Notifications
You must be signed in to change notification settings - Fork 225
/
Copy pathdb_tunables.c
1850 lines (1604 loc) · 52.8 KB
/
db_tunables.c
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 2017 Bloomberg Finance L.P.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "comdb2.h"
#include "tunables.h"
#include "logmsg.h"
#include "util.h"
#include "analyze.h"
#include "intern_strings.h"
#include "portmuxapi.h"
#include "config.h"
#include "net.h"
#include "sql_stmt_cache.h"
#include "sc_rename_table.h"
#include "views.h"
/* Maximum allowable size of the value of tunable. */
#define MAX_TUNABLE_VALUE_SIZE 512
/* Separator for composite tunable components. */
#define COMPOSITE_TUNABLE_SEP '.'
extern int gbl_waitalive_iterations;
extern int gbl_allow_anon_id_for_spmux;
extern int gbl_allow_lua_print;
extern int gbl_allow_lua_dynamic_libs;
extern int gbl_allow_pragma;
extern int gbl_berkdb_epochms_repts;
extern int gbl_pmux_route_enabled;
extern int gbl_allow_user_schema;
extern int gbl_test_badwrite_intvl;
extern int gbl_broken_max_rec_sz;
extern int gbl_broken_num_parser;
extern int gbl_crc32c;
extern int gbl_decom;
extern int gbl_disable_rowlocks;
extern int gbl_disable_rowlocks_logging;
extern int gbl_stack_at_lock_get;
extern int gbl_stack_at_page_read;
extern int gbl_stack_at_page_write;
extern int gbl_stack_at_lock_handle;
extern int gbl_stack_at_write_lock;
extern int gbl_stack_at_lock_gen_increment;
extern int gbl_disable_skip_rows;
extern int gbl_disable_sql_dlmalloc;
extern int gbl_enable_berkdb_retry_deadlock_bias;
extern int gbl_enable_cache_internal_nodes;
extern int gbl_partial_indexes;
extern int gbl_force_writesql;
extern int gbl_sparse_lockerid_map;
extern int gbl_spstrictassignments;
extern int gbl_early;
extern int gbl_enque_reorder_lookahead;
extern int gbl_exit_alarm_sec;
extern int gbl_fdb_track;
extern int gbl_fdb_track_hints;
extern int gbl_forbid_ulonglong;
extern int gbl_force_highslot;
extern int gbl_fdb_allow_cross_classes;
extern int gbl_fdb_resolve_local;
extern int gbl_fdb_push_redirect_foreign;
extern int gbl_fdb_push_remote;
extern int gbl_goslow;
extern int gbl_heartbeat_send;
extern int gbl_keycompr;
extern int gbl_llmeta_pagesize;
extern int gbl_largepages;
extern int gbl_loghist;
extern int gbl_loghist_verbose;
extern int gbl_master_retry_poll_ms;
extern int gbl_debug_blkseq_race;
extern int gbl_debug_stat4dump_loop;
extern int gbl_master_swing_osql_verbose;
extern int gbl_master_swing_sock_restart_sleep;
extern int gbl_max_lua_instructions;
extern int gbl_max_sqlcache;
extern int __gbl_max_mpalloc_sleeptime;
extern int gbl_mem_nice;
extern int gbl_netbufsz;
extern int gbl_net_lmt_upd_incoherent_nodes;
extern int gbl_net_max_mem;
extern int gbl_net_throttle_percent;
extern int gbl_notimeouts;
extern int gbl_watchdog_disable_at_start;
extern int gbl_osql_verify_retries_max;
extern int gbl_dump_history_on_too_many_verify_errors;
extern int gbl_page_latches;
extern int gbl_pb_connectmsg;
extern int gbl_prefault_udp;
extern int gbl_print_syntax_err;
extern int gbl_lclpooled_buffers;
extern int gbl_reallyearly;
extern int gbl_rep_mon_threshold;
extern int gbl_repdebug;
extern int gbl_replicant_latches;
extern int gbl_return_long_column_names;
extern int gbl_round_robin_stripes;
extern int skip_clear_queue_extents;
extern int gbl_rep_skip_recovery;
extern int gbl_retrieve_gen_from_ckp;
extern int gbl_recovery_ckp;
extern int gbl_reproduce_ckp_bug;
extern int gbl_slow_rep_process_txn_freq;
extern int gbl_slow_rep_process_txn_minms;
extern int gbl_slow_rep_process_txn_maxms;
extern int gbl_sqlite_sorter_mem;
extern int gbl_sqlite_use_temptable_for_rowset;
extern int gbl_allow_bplog_restarts;
extern int gbl_sqlite_stat4_scan;
extern int gbl_test_blob_race;
extern int gbl_llmeta_deadlock_poll;
extern int gbl_test_scindex_deadlock;
extern int gbl_test_sc_resume_race;
extern int gbl_track_weighted_queue_metrics_separately;
extern int gbl_typessql;
extern int gbl_typessql_records_max;
extern int gbl_berkdb_track_locks;
extern int gbl_db_lock_maxid_override;
extern int gbl_udp;
extern int gbl_update_delete_limit;
extern int gbl_updategenids;
extern int gbl_use_appsock_as_sqlthread;
extern int gbl_use_node_pri;
extern int gbl_watchdog_watch_threshold;
extern int portmux_port;
extern int g_osql_max_trans;
extern int gbl_osql_max_throttle_sec;
extern int gbl_osql_random_restart;
extern int gbl_toblock_random_deadlock_trans;
extern int diffstat_thresh;
extern int reqltruncate;
extern int analyze_max_comp_threads;
extern int analyze_max_table_threads;
extern int gbl_always_reload_analyze;
extern int gbl_block_set_commit_genid_trace;
extern int gbl_random_prepare_commit;
extern int gbl_all_prepare_commit;
extern int gbl_all_prepare_abort;
extern int gbl_all_prepare_leak;
extern int gbl_flush_on_prepare;
extern int gbl_abort_on_unset_ha_flag;
extern int gbl_abort_on_unfound_txn;
extern int gbl_abort_on_ufid_mismatch;
extern int gbl_write_dummy_trace;
extern int gbl_abort_on_incorrect_upgrade;
extern int gbl_poll_in_pg_free_recover;
extern int gbl_print_deadlock_cycles;
extern int gbl_always_send_cnonce;
extern int gbl_rep_badgen_trace;
extern int gbl_dump_zero_coherency_timestamp;
extern int gbl_allow_incoherent_sql;
extern int gbl_rep_process_msg_print_rc;
extern int gbl_verbose_master_req;
extern int gbl_verbose_send_coherency_lease;
extern int gbl_reset_on_unelectable_cluster;
extern int gbl_rep_verify_always_grab_writelock;
extern int gbl_rep_verify_will_recover_trace;
extern uint32_t gbl_written_rows_warn;
extern uint32_t gbl_max_wr_rows_per_txn;
extern uint32_t gbl_max_cascaded_rows_per_txn;
extern uint32_t gbl_max_time_per_txn_ms;
extern int gbl_force_serial_on_writelock;
extern int gbl_processor_thd_poll;
extern int gbl_time_rep_apply;
extern int gbl_incoherent_logput_window;
extern int gbl_dump_net_queue_on_partial_write;
extern int gbl_dump_full_net_queue;
extern int gbl_debug_partial_write;
extern int gbl_debug_sleep_on_analyze;
extern int gbl_debug_sleep_on_verify;
extern int gbl_max_clientstats_cache;
extern int gbl_decoupled_logputs;
extern int gbl_dedup_rep_all_reqs;
extern int gbl_apply_queue_memory;
extern int gbl_inmem_repdb;
extern int gbl_inmem_repdb_maxlog;
extern int gbl_inmem_repdb_memory;
extern int gbl_net_writer_thread_poll_ms;
extern int gbl_max_apply_dequeue;
extern int gbl_catchup_window_trace;
extern int gbl_early_ack_trace;
extern int gbl_commit_delay_timeout;
extern int gbl_commit_delay_copy_ms;
extern int gbl_commit_lsn_map;
extern int gbl_throttle_logput_trace;
extern int gbl_fills_waitms;
extern int gbl_finish_fill_threshold;
extern int gbl_long_read_threshold;
extern int gbl_always_ack_fills;
extern int gbl_verbose_fills;
extern int gbl_getlock_latencyms;
extern int gbl_last_locked_seqnum;
extern int gbl_set_coherent_state_trace;
extern int gbl_incoherent_slow_inactive_timeout;
extern int gbl_force_incoherent;
extern int gbl_force_incoherent_master;
extern int gbl_ignore_coherency;
extern int gbl_skip_catchup_logic;
extern int gbl_debug_downgrade_cluster_at_open;
extern int gbl_forbid_incoherent_writes;
extern int gbl_durable_set_trace;
extern int gbl_set_seqnum_trace;
extern int gbl_enque_log_more;
extern int gbl_trace_repmore_reqs;
extern int gbl_verbose_repdups;
extern int gbl_apply_thread_pollms;
extern int gbl_warn_queue_latency_threshold;
extern int gbl_req_all_threshold;
extern int gbl_req_all_time_threshold;
extern int gbl_req_delay_count_threshold;
extern int gbl_dbreg_stack_on_null_txn;
extern int gbl_dbreg_abort_on_null_txn;
extern int gbl_simulate_dropping_request;
extern int gbl_max_logput_queue;
extern int gbl_blocking_enque;
extern int gbl_master_req_waitms;
extern int gbl_print_net_queue_size;
extern int gbl_commit_delay_trace;
extern int gbl_elect_priority_bias;
extern int gbl_abort_on_reconstruct_failure;
extern int gbl_rand_elect_timeout;
extern uint32_t gbl_rand_elect_min_ms;
extern int gbl_rand_elect_max_ms;
extern int gbl_handle_buf_add_latency_ms;
extern int gbl_osql_send_startgen;
extern int gbl_create_default_user;
extern int gbl_allow_neg_column_size;
extern int gbl_client_heartbeat_ms;
extern int gbl_rep_wait_release_ms;
extern int gbl_rep_wait_core_ms;
extern int gbl_random_get_curtran_failures;
extern int gbl_txn_fop_noblock;
extern int gbl_debug_random_block_on_fop;
extern int gbl_random_thdpool_work_timeout;
extern int gbl_thdpool_queue_only;
extern int gbl_random_sql_work_delayed;
extern int gbl_random_sql_work_rejected;
extern int gbl_instrument_dblist;
extern int gbl_replicated_truncate_timeout;
extern int gbl_match_on_ckp;
extern int gbl_verbose_set_sc_in_progress;
extern int gbl_send_failed_dispatch_message;
extern int gbl_logdelete_lock_trace;
extern int gbl_flush_log_at_checkpoint;
extern int gbl_online_recovery;
extern int gbl_forbid_remote_admin;
extern int gbl_abort_on_dta_lookup_error;
extern int gbl_debug_children_lock;
extern int gbl_serialize_reads_like_writes;
extern int gbl_long_log_truncation_warn_thresh_sec;
extern int gbl_long_log_truncation_abort_thresh_sec;
extern int gbl_snapshot_serial_verify_retry;
extern int gbl_cache_flush_interval;
extern int gbl_load_cache_threads;
extern int gbl_load_cache_max_pages;
extern int gbl_dump_cache_max_pages;
extern int gbl_max_pages_per_cache_thread;
extern int gbl_memp_dump_cache_threshold;
extern int gbl_disable_ckp;
extern int gbl_abort_on_illegal_log_put;
extern int gbl_sc_close_txn;
extern int gbl_master_sends_query_effects;
extern int gbl_create_dba_user;
extern int gbl_lock_dba_user;
extern int gbl_dump_sql_on_repwait_sec;
extern int gbl_client_queued_slow_seconds;
extern int gbl_client_running_slow_seconds;
extern int gbl_client_abort_on_slow;
extern int gbl_max_trigger_threads;
extern int gbl_alternate_normalize;
extern int gbl_sc_logbytes_per_second;
extern int gbl_fingerprint_max_queries;
extern int gbl_query_plan_max_plans;
extern double gbl_query_plan_percentage;
extern int gbl_ufid_log;
extern int gbl_utxnid_log;
extern int gbl_ufid_add_on_collect;
extern int gbl_collect_before_locking;
extern unsigned gbl_ddlk;
extern int gbl_abort_on_missing_ufid;
extern int gbl_ufid_dbreg_test;
extern int gbl_debug_add_replication_latency;
extern int gbl_javasp_early_release;
extern int gbl_debug_drop_nth_rep_message;
extern long long sampling_threshold;
extern size_t gbl_lk_hash;
extern size_t gbl_lk_parts;
extern size_t gbl_lkr_hash;
extern size_t gbl_lkr_parts;
extern uint8_t _non_dedicated_subnet;
extern char *gbl_crypto;
extern char *gbl_spfile_name;
extern char *gbl_user_vers_spfile_name;
extern char *gbl_timepart_file_name;
extern char *gbl_test_log_file;
extern pthread_mutex_t gbl_test_log_file_mtx;
extern char *gbl_machine_class;
extern int gbl_ref_sync_pollms;
extern int gbl_ref_sync_wait_txnlist;
extern int gbl_ref_sync_iterations;
extern int gbl_sc_pause_at_end;
extern int gbl_sc_is_at_end;
extern int gbl_max_password_cache_size;
extern int gbl_check_constraint_feature;
extern int gbl_verify_default_function;
extern int gbl_default_function_feature;
extern int gbl_on_del_set_null_feature;
extern int gbl_sequence_feature;
extern int gbl_reproduce_sequence_corruption;
extern int gbl_permissive_sequence_sc;
extern int gbl_view_feature;
extern char *gbl_kafka_topic;
extern char *gbl_kafka_brokers;
extern int gbl_noleader_retry_duration_ms;
extern int gbl_noleader_retry_poll_ms;
/* util/ctrace.c */
extern int nlogs;
extern unsigned long long rollat;
/* util/thread_util.c */
extern int thread_debug;
extern int dump_resources_on_thread_exit;
/* util/walkback.c */
extern int gbl_walkback_enabled;
extern int gbl_warnthresh;
/* bdb/bdb_net.c */
extern int gbl_ack_trace;
/* bdb/bdblock.c */
extern int gbl_bdblock_debug;
extern int gbl_debug_aa;
/* bdb/os_namemangle_46.c */
extern int gbl_namemangle_loglevel;
/* berkdb/rep/rep_record.c */
extern int max_replication_trans_retries;
/* net/net.c */
extern int explicit_flush_trace;
/* bdb/file.c */
extern char *bdb_trans(const char infile[], char outfile[]);
/* bdb/genid.c */
unsigned long long get_genid(bdb_state_type *bdb_state, unsigned int dtafile);
void seed_genid48(bdb_state_type *bdb_state, uint64_t seed);
extern int set_pbkdf2_iterations(int val);
static char *gbl_name = NULL;
static int ctrace_gzip;
extern int gbl_reorder_socksql_no_deadlock;
int gbl_ddl_cascade_drop = 1;
extern int gbl_queuedb_genid_filename;
extern int gbl_queuedb_file_threshold;
extern int gbl_queuedb_file_interval;
extern int gbl_queuedb_timeout_sec;
extern int gbl_timeseries_metrics;
extern int gbl_metric_maxpoints;
extern int gbl_metric_maxage;
extern int gbl_abort_irregular_set_durable_lsn;
extern int gbl_legacy_defaults;
extern int gbl_legacy_schema;
extern int gbl_selectv_writelock_on_update;
extern int gbl_selectv_writelock;
extern int gbl_msgwaittime;
extern int gbl_scwaittime;
extern int gbl_reorder_idx_writes;
extern int gbl_perform_full_clean_exit;
extern int gbl_clean_exit_on_sigterm;
extern int gbl_abort_on_dangling_stringrefs;
extern int gbl_debug_omit_dta_write;
extern int gbl_debug_omit_idx_write;
extern int gbl_debug_omit_blob_write;
extern int gbl_debug_skip_constraintscheck_on_insert;
extern int gbl_debug_pb_connectmsg_dbname_check;
extern int gbl_debug_pb_connectmsg_gibberish;
extern int gbl_debug_omit_zap_on_rebuild;
extern int gbl_debug_txn_sleep;
extern int gbl_instrument_consumer_lock;
extern int gbl_reject_mixed_ddl_dml;
extern int gbl_debug_create_master_entry;
extern int eventlog_nkeep;
extern int gbl_debug_systable_locks;
extern int gbl_assert_systable_locks;
extern int gbl_track_curtran_gettran_locks;
extern int gbl_permit_small_sequences;
extern int gbl_debug_sleep_in_sql_tick;
extern int gbl_debug_sleep_in_analyze;
extern int gbl_debug_sleep_in_summarize;
extern int gbl_debug_sleep_in_trigger_info;
extern int gbl_protobuf_prealloc_buffer_size;
extern int gbl_replicant_retry_on_not_durable;
extern int gbl_enable_internal_sql_stmt_caching;
extern int gbl_longreq_log_freq_sec;
extern int gbl_disable_seekscan_optimization;
extern int gbl_pgcomp_dryrun;
extern int gbl_pgcomp_dbg_stdout;
extern int gbl_pgcomp_dbg_ctrace;
extern int gbl_warn_on_equiv_type_mismatch;
extern int gbl_warn_on_equiv_types;
extern int gbl_fdb_incoherence_percentage;
extern int gbl_fdb_io_error_retries;
extern int gbl_fdb_io_error_retries_phase_1;
extern int gbl_fdb_io_error_retries_phase_2_poll;
extern int gbl_fdb_auth_enabled;
extern int gbl_debug_invalid_genid;
/* Tranlog */
extern int gbl_tranlog_incoherent_timeout;
extern int gbl_tranlog_default_timeout;
extern int gbl_tranlog_maxpoll;
/* Physical replication */
extern int gbl_blocking_physrep;
extern int gbl_physrep_check_minlog_freq_sec;
extern int gbl_physrep_debug;
extern int gbl_physrep_exit_on_invalid_logstream;
extern int gbl_physrep_fanout;
extern int gbl_physrep_hung_replicant_check_freq_sec;
extern int gbl_physrep_hung_replicant_threshold;
extern int gbl_physrep_revconn_check_interval;
extern int gbl_physrep_update_registry_interval;
extern int gbl_physrep_i_am_metadb;
extern int gbl_physrep_keepalive_v2;
extern int gbl_physrep_keepalive_freq_sec;
extern int gbl_physrep_max_candidates;
extern int gbl_physrep_max_pending_replicants;
extern int gbl_physrep_reconnect_penalty;
extern int gbl_physrep_reconnect_interval;
extern int gbl_physrep_shuffle_host_list;
extern int gbl_physrep_ignore_queues;
extern int gbl_physrep_max_rollback;
/* source-name / host is from lrl */
extern char *gbl_physrep_source_dbname;
extern int gbl_physrep_source_dbnum;
extern int gbl_query_comdb2db_for_absent_physrep_source_dbnum;
extern char *gbl_physrep_source_host;
/* meta-name / host is from lrl */
extern char *gbl_physrep_metadb_name;
extern char *gbl_physrep_metadb_host;
/* repl-name / host is the active connection */
extern char *gbl_physrep_repl_name;
extern char *gbl_physrep_repl_host;
/* class-mach cache */
extern int gbl_class_machs_refresh;
/* Reversql connection/sql */
extern int gbl_revsql_allow_command_exec;
extern int gbl_revsql_debug;
extern int gbl_revsql_cdb2_debug;
extern int gbl_revsql_host_refresh_freq_sec;
extern int gbl_revsql_connect_freq_sec;
extern int gbl_revsql_force_rte;
extern int gbl_revsql_fake_connect_failure;
extern int gbl_connect_remote_rte;
extern int gbl_reverse_hosts_v2;
extern int gbl_abort_on_invalid_close;
int gbl_debug_tmptbl_corrupt_mem;
int gbl_group_concat_mem_limit; /* 0 implies allow upto SQLITE_MAX_LENGTH,
sqlite's limit */
int gbl_page_order_table_scan;
int gbl_old_column_names = 1;
int gbl_enable_sq_flattening_optimization = 1;
int gbl_mask_internal_tunables = 1;
int gbl_allow_readonly_runtime_mod = 0;
size_t gbl_cached_output_buffer_max_bytes = 8 * 1024 * 1024; /* 8 MiB */
int gbl_sqlite_sorterpenalty = 5;
int gbl_file_permissions = 0660;
extern int gbl_net_maxconn;
extern int gbl_force_direct_io;
extern int gbl_seekscan_maxsteps;
extern int gbl_wal_osync;
extern uint64_t gbl_sc_headroom;
extern int gbl_unexpected_last_type_warn;
extern int gbl_unexpected_last_type_abort;
extern int gbl_pstack_self;
/* For fdb connections using cdb2api */
extern char *gbl_cdb2api_policy_override;
extern int gbl_timer_pstack_interval;
extern int gbl_timer_warn_interval;
int gbl_incoherent_clnt_wait = 0;
int gbl_new_leader_duration = 3;
extern int gbl_transaction_grace_period;
extern int gbl_sc_7format;
extern int gbl_dohsql_joins;
extern int gbl_sc_history_max_rows;
extern int gbl_sc_status_max_rows;
extern int gbl_chk_desc_skipscan;
extern int gbl_sqlite_limit_var_optimization;
extern int gbl_rep_process_pstack_time;
extern int gbl_sqlite_interstage_optimization;
/*
=========================================================
Value/Update/Verify functions for some tunables that need
special treatment.
=========================================================
*/
static void *init_with_compr_value(void *context)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
return (void *)bdb_algo2compr(*(int *)tunable->var);
}
static int init_with_compr_update(void *context, void *algo)
{
gbl_init_with_compr = bdb_compr2algo((char *)algo);
logmsg(LOGMSG_INFO, "New tables will be compressed: %s\n",
bdb_algo2compr(gbl_init_with_compr));
return 0;
}
static int init_with_compr_blobs_update(void *context, void *algo)
{
gbl_init_with_compr_blobs = bdb_compr2algo((char *)algo);
logmsg(LOGMSG_INFO, "Blobs in new tables will be compressed: %s\n",
bdb_algo2compr(gbl_init_with_compr_blobs));
return 0;
}
static int init_with_queue_compr_update(void *context, void *algo)
{
gbl_init_with_queue_compr = bdb_compr2algo((char *)algo);
logmsg(LOGMSG_INFO, "New queues will be compressed: %s\n",
bdb_algo2compr(gbl_init_with_queue_compr));
return 0;
}
static int init_with_rowlocks_update(void *context, void *unused)
{
gbl_init_with_rowlocks = 1;
return 0;
}
static int init_with_rowlocks_master_only_update(void *context, void *unused)
{
gbl_init_with_rowlocks = 2;
return 0;
}
/* A generic function to check if the specified number is >= 0 & <= 100. */
int percent_verify(void *unused, void *percent)
{
if (*(int *)percent < 0 || *(int *)percent > 100) {
logmsg(LOGMSG_ERROR,
"Invalid value for tunable; should be in range [0, 100].\n");
return 1;
}
return 0;
}
struct enable_sql_stmt_caching_st {
const char *name;
int code;
} enable_sql_stmt_caching_vals[] = {{"NONE", STMT_CACHE_NONE},
{"PARAM", STMT_CACHE_PARAM},
{"ALL", STMT_CACHE_ALL}};
static int enable_sql_stmt_caching_update(void *context, void *value)
{
comdb2_tunable *tunable;
char *tok;
int st = 0;
int ltok;
int len;
tunable = (comdb2_tunable *)context;
if ((tunable->flags & EMPTY) != 0) {
/* Backward compatibility */
*(int *)tunable->var = STMT_CACHE_PARAM;
} else {
len = strlen(value);
tok = segtok(value, len, &st, <ok);
for (int i = 0; i < (sizeof(enable_sql_stmt_caching_vals) /
sizeof(struct enable_sql_stmt_caching_st));
i++) {
if (tokcmp(tok, ltok, enable_sql_stmt_caching_vals[i].name) == 0) {
*(int *)tunable->var = enable_sql_stmt_caching_vals[i].code;
break;
}
}
}
return 0;
}
static void *enable_sql_stmt_caching_value(void *context)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
for (int i = 0; i < (sizeof(enable_sql_stmt_caching_vals) /
sizeof(struct enable_sql_stmt_caching_st));
i++) {
if (enable_sql_stmt_caching_vals[i].code == *(int *)tunable->var) {
return (void *)enable_sql_stmt_caching_vals[i].name;
}
}
return "unknown";
}
struct checkctags_st {
const char *name;
int code;
} checkctags_vals[] = {{"OFF", 0}, {"FULL", 1}, {"SOFT", 2}};
static int checkctags_update(void *context, void *value)
{
comdb2_tunable *tunable;
char *tok;
int st = 0;
int ltok;
int len;
tunable = (comdb2_tunable *)context;
len = strlen(value);
tok = segtok(value, len, &st, <ok);
for (int i = 0;
i < (sizeof(checkctags_vals) / sizeof(struct checkctags_st)); i++) {
if (tokcmp(tok, ltok, checkctags_vals[i].name) == 0) {
*(int *)tunable->var = checkctags_vals[i].code;
return 0;
}
}
return 1;
}
static void *checkctags_value(void *context)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
for (int i = 0;
i < (sizeof(checkctags_vals) / sizeof(struct checkctags_st)); i++) {
if (checkctags_vals[i].code == *(int *)tunable->var) {
return (void *)checkctags_vals[i].name;
}
}
return "unknown";
}
static void *next_genid_value(void *context)
{
/*comdb2_tunable *tunable = (comdb2_tunable *)context;*/
static char genid_str[64];
unsigned long long flipgenid, genid = get_genid(thedb->bdb_env, 0);
int *genptr = (int *)&genid, *flipptr = (int *)&flipgenid;
flipptr[0] = htonl(genptr[1]);
flipptr[1] = htonl(genptr[0]);
snprintf(genid_str, sizeof(genid_str), "0x%016llx 0x%016llx %llu", genid,
flipgenid, genid);
return (void *)genid_str;
}
static int genid_seed_update(void *context, void *value)
{
/*comdb2_tunable *tunable = (comdb2_tunable *)context;*/
char *seedstr = (char *)value;
unsigned long long seed;
seed = strtoll(seedstr, 0, 16);
seed_genid48(thedb->bdb_env, seed);
return 0;
}
/*
Enable client side retrys for n seconds. Keep blkseq's around
for 2 * this time.
*/
static int retry_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
int val = *(int *)value;
/*
For now the proxy will treat the number 180 as meaning "this is
old comdb2.tsk which defaults to 180 seconds", so we put in this
HACK!!!! to get around that. Remove this hack when this build of
comdb2.tsk is everywhere.
*/
if (val == 180) {
val = 181;
}
*(int *)tunable->var = val;
return 0;
}
static int maxt_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
int val = *(int *)value;
*(int *)tunable->var = val;
if (gbl_maxwthreads > gbl_maxthreads) {
logmsg(LOGMSG_INFO,
"Reducing max number of writer threads in lrl to %d\n", val);
gbl_maxwthreads = val;
}
return 0;
}
static int maxq_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
int val = *(int *)value;
/* Can't be more than swapinit! */
if ((val < 1) || (val > 1000)) {
logmsg(LOGMSG_ERROR, "Invalid value for tunable '%s'\n", tunable->name);
return 1;
}
*(int *)tunable->var = val;
return 0;
}
static int file_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
int len = strlen((char *)value);
int st = 0;
int ltok;
char *tok = segtok(value, len, &st, <ok);
char *file_tmp = tokdup(tok, ltok);
free(*(char **)tunable->var);
*(char **)tunable->var = getdbrelpath(file_tmp);
free(file_tmp);
return 0;
}
static int lk_verify(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
if ((*(int *)value <= 0) || (*(int *)value > 2048)) {
logmsg(LOGMSG_ERROR, "Invalid value for '%s'. (range: 1-2048)\n",
tunable->name);
return 1;
}
return 0;
}
static int memnice_update(void *context, void *value)
{
int nicerc;
nicerc = comdb2ma_nice(*(int *)value);
if (nicerc != 0) {
logmsg(LOGMSG_ERROR, "Failed to change mem niceness: rc = %d\n",
nicerc);
return 1;
}
return 0;
}
int dtastripe_verify(void *context, void *stripes)
{
int iStripes = *(int *)stripes;
if ((iStripes < 1) || (iStripes > 16)) {
return 1;
}
return 0;
}
static int maxretries_verify(void *context, void *value)
{
if (*(int *)value < 2) {
return 1;
}
return 0;
}
static int maxcolumns_verify(void *context, void *value)
{
if (*(int *)value <= 0 || *(int *)value > MAXCOLUMNS) {
return 1;
}
return 0;
}
static int loghist_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
if ((tunable->flags & EMPTY) != 0) {
*(int *)tunable->var = 10000;
} else {
*(int *)tunable->var = *(int *)value;
}
return 0;
}
static int page_compact_target_ff_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
if ((tunable->flags & EMPTY) != 0) {
*(double *)tunable->var = 0.693;
} else {
*(double *)tunable->var = *(double *)value / 100.0F;
}
return 0;
}
static int page_compact_thresh_ff_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
double val;
if ((tunable->flags & EMPTY) != 0) {
val = 0.346;
} else {
val = *(double *)value / 100.0F;
}
*(double *)tunable->var = val;
return 0;
}
/* TODO(Nirbhay) : Test */
static int blob_mem_mb_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
int val = *(int *)value;
if (val == -1) {
*(int *)tunable->var = -1;
} else {
*(int *)tunable->var = (1 << 20) * val;
}
return 0;
}
/* TODO(Nirbhay) : Test */
static int blobmem_sz_thresh_kb_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
*(int *)tunable->var = 1024 * (*(int *)value);
return 0;
}
static int enable_upgrade_ahead_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
if ((tunable->flags & EMPTY) != 0) {
*(int *)tunable->var = 32;
} else {
*(int *)tunable->var = *(int *)value;
}
return 0;
}
static int broken_max_rec_sz_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
int val = *(int *)value;
if (val >= 1024) {
*(int *)tunable->var = 512;
} else {
*(int *)tunable->var = val;
}
logmsg(LOGMSG_INFO, "Allow db to start with max record size of %d\n",
COMDB2_MAX_RECORD_SIZE + gbl_broken_max_rec_sz);
return 0;
}
static int netconndumptime_update(void *context, void *value)
{
int val = *(int *)value;
net_set_conntime_dump_period(thedb->handle_sibling, val);
return 0;
}
static void *netconndumptime_value(void *context)
{
static char val[64];
sprintf(val, "%d", net_get_conntime_dump_period(thedb->handle_sibling));
return val;
}
const char *deadlock_policy_str(u_int32_t policy);
int deadlock_policy_max();
static int deadlock_policy_override_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
int val = *(int *)value;
if (val > deadlock_policy_max()) {
return 1;
}
*(int *)tunable->var = val;
logmsg(LOGMSG_INFO, "Set deadlock policy to %s\n",
deadlock_policy_str(val));
return 0;
}
extern void clean_exit_sigwrap(int signum);
static int update_clean_exit_on_sigterm(void *context, void *value) {
int val = *(int *)value;
if (val)
signal(SIGTERM, clean_exit_sigwrap);
else
signal(SIGTERM, SIG_DFL);
gbl_clean_exit_on_sigterm = val;
return 0;
}
static int osql_heartbeat_alert_time_verify(void *context, void *value)
{
if ((*(int *)value <= 0) || (*(int *)value > gbl_osql_heartbeat_send)) {
logmsg(LOGMSG_ERROR, "Invalid heartbeat alert time, need to define "
"osql_heartbeat_send_time first.\n");
return 1;
}
return 0;
}
static int simulate_rowlock_deadlock_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
if (*(int *)value == 0) {
logmsg(LOGMSG_INFO, "Disabling rowlock_deadlock simulator.\n");
} else if (*(int *)value < 2) {
logmsg(LOGMSG_ERROR, "Invalid rowlock_deadlock interval.\n");
return 1;
} else {
logmsg(LOGMSG_INFO, "Will throw a rowlock deadlock every %d tries.\n",
*(int *)value);
}
*(int *)tunable->var = *(int *)value;
return 0;
}
static int log_delete_after_backup_update(void *context, void *unused)
{
logmsg(LOGMSG_USER, "Will delete log files after backup\n");