Created
July 19, 2017 12:43
-
-
Save nirbhayc/39610efdef03f46f3862db605bc4737e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/bbinc/tunables.h b/bbinc/tunables.h | |
index eb1d5d1..41263b2 100644 | |
--- a/bbinc/tunables.h | |
+++ b/bbinc/tunables.h | |
@@ -59,6 +59,9 @@ typedef enum { | |
/* Set this flag if no argument has been specified. */ | |
EMPTY = 1 << 8, | |
+ | |
+ /* Set this flag if the tunable needs to be read early during startup. */ | |
+ READEARLY = 1 << 9 | |
} comdb2_tunable_flag; | |
/* | |
diff --git a/db/comdb2.c b/db/comdb2.c | |
index c75efdc..87eba32 100644 | |
--- a/db/comdb2.c | |
+++ b/db/comdb2.c | |
@@ -1868,43 +1868,19 @@ static int pre_read_option(struct dbenv *dbenv, char *line, | |
add_legacy_default_options(dbenv); | |
} | |
- if (tokcmp(tok, ltok, "disable_direct_writes") == 0) { | |
- dbenv->enable_direct_writes = 0; | |
- } else if (tokcmp(tok, ltok, "morecolumns") == 0) { | |
- logmsg(LOGMSG_INFO, "allowing 1024 columns per table\n"); | |
- gbl_morecolumns = 1; | |
- } else if (tokcmp(tok, ltok, "nullfkey") == 0) { | |
- gbl_nullfkey = 1; | |
- } else if (tokcmp(tok, ltok, "disallow_portmux_route") == 0) { | |
- gbl_pmux_route_enabled = 0; | |
- logmsg(LOGMSG_INFO, "Won't allow portmux route\n"); | |
- } else if (tokcmp(tok, ltok, "allow_portmux_route") == 0) { | |
- gbl_pmux_route_enabled = 1; | |
- logmsg(LOGMSG_INFO, "Will allow portmux route\n"); | |
- } else if (tokcmp(tok, ltok, "portmux_port") == 0) { | |
- tok = segtok(line, llen, &st, <ok); | |
- int portmux_port = toknum(tok, ltok); | |
- logmsg(LOGMSG_WARN, "Using portmux port %d\n", portmux_port); | |
- set_portmux_port(portmux_port); | |
- } else if (tokcmp(tok, ltok, "portmux_bind_path") == 0) { | |
- char path[108]; | |
- tok = segtok(line, llen, &st, <ok); | |
- tokcpy(tok, ltok, path); | |
- if (set_portmux_bind_path(path)) { | |
- logmsg(LOGMSG_ERROR, "Failed in setting portmux bind path %s\n", | |
- path); | |
- } else { | |
- logmsg(LOGMSG_INFO, "Using portmux bind path %s\n", path); | |
- } | |
- } else if (tokcmp(line, ltok, "hostname") == 0) { | |
- tok = segtok(line, llen, &st, <ok); | |
- if (ltok == 0) { | |
- logmsg(LOGMSG_INFO, "Expected hostname for 'hostname' directive.\n"); | |
- return -1; | |
- } | |
- gbl_mynode = internn(tok, ltok); | |
- getmyaddr(); | |
- } else if (tokcmp(line, ltok, "logmsg") == 0) { | |
+ /* | |
+ Handle global tunables which are supposed to be read early. | |
+ | |
+ rc == -1 : non-registered tunable, fallthrough | |
+ rc == 0 : tunable updated successfully, return | |
+ rc == 1 : error while updating the tunable, return | |
+ */ | |
+ rc = handle_lrl_tunable(tok, ltok, line + st, len - st, READEARLY); | |
+ if (rc != -1) { | |
+ return rc; | |
+ } | |
+ | |
+ if (tokcmp(line, ltok, "logmsg") == 0) { | |
logmsg_process_message(line, llen); | |
} | |
return 0; | |
@@ -2158,7 +2134,7 @@ static int read_lrl_option(struct dbenv *dbenv, char *line, void *p, int len) | |
rc == 0 : tunable updated successfully, return | |
rc == 1 : error while updating the tunable, return | |
*/ | |
- rc = handle_lrl_tunable(tok, ltok, line + st, len - st); | |
+ rc = handle_lrl_tunable(tok, ltok, line + st, len - st, 0); | |
if (rc != -1) { | |
return rc; | |
} | |
diff --git a/db/comdb2.h b/db/comdb2.h | |
index 1302464..2d7b3f6 100644 | |
--- a/db/comdb2.h | |
+++ b/db/comdb2.h | |
@@ -3641,6 +3641,7 @@ extern int gbl_upd_null_cstr_return_conv_err; | |
/* Update the tunable at runtime. */ | |
int handle_runtime_tunable(const char *name, const char *value); | |
/* Update the tunable read from lrl file. */ | |
-int handle_lrl_tunable(char *name, int name_len, char *value, int value_len); | |
+int handle_lrl_tunable(char *name, int name_len, char *value, int value_len, | |
+ int flags); | |
#endif /* !INCLUDED_COMDB2_H */ | |
diff --git a/db/db_tunables.c b/db/db_tunables.c | |
index e9959ff..a1f9ef3 100644 | |
--- a/db/db_tunables.c | |
+++ b/db/db_tunables.c | |
@@ -1139,7 +1139,8 @@ int handle_runtime_tunable(const char *name, const char *value) | |
-1 Not a registered tunable | |
*/ | |
-int handle_lrl_tunable(char *name, int name_len, char *value, int value_len) | |
+int handle_lrl_tunable(char *name, int name_len, char *value, int value_len, | |
+ int flags) | |
{ | |
comdb2_tunable *t; | |
char buf[MAX_TUNABLE_VALUE_SIZE]; | |
@@ -1159,6 +1160,10 @@ int handle_lrl_tunable(char *name, int name_len, char *value, int value_len) | |
return -1; | |
} | |
+ /* Only proceed if we were asked to process READEARLY tunables. */ | |
+ if ((flags & READEARLY) && ((t->flags & READEARLY) == 0)) | |
+ return 0; | |
+ | |
/* Check if we have a value specified after the name. */ | |
tok = segtok(value, value_len, &st, <ok); | |
if (ltok == 0) { | |
diff --git a/db/db_tunables.h b/db/db_tunables.h | |
index 1453534..7bf96a2 100644 | |
--- a/db/db_tunables.h | |
+++ b/db/db_tunables.h | |
@@ -36,8 +36,8 @@ REGISTER_TUNABLE("allow_lua_print", "Enable to allow stored " | |
TUNABLE_BOOLEAN, &gbl_allow_lua_print, READONLY | NOARG, NULL, | |
NULL, NULL, NULL); | |
REGISTER_TUNABLE("allow_portmux_route", NULL, TUNABLE_BOOLEAN, | |
- &gbl_pmux_route_enabled, READONLY | NOARG, NULL, NULL, NULL, | |
- NULL); | |
+ &gbl_pmux_route_enabled, READONLY | NOARG | READEARLY, NULL, | |
+ NULL, NULL, NULL); | |
REGISTER_TUNABLE("allow_user_schema", | |
"Enable to allow per-user schemas. (Default: off)", | |
TUNABLE_BOOLEAN, &gbl_allow_user_schema, READONLY | NOARG, | |
@@ -88,8 +88,8 @@ REGISTER_TUNABLE("broken_max_rec_sz", NULL, TUNABLE_INTEGER, | |
&gbl_broken_max_rec_sz, READONLY, NULL, NULL, | |
broken_max_rec_sz_update, NULL); | |
REGISTER_TUNABLE("broken_num_parser", NULL, TUNABLE_BOOLEAN, | |
- &gbl_broken_num_parser, READONLY | NOARG, NULL, NULL, NULL, | |
- NULL); | |
+ &gbl_broken_num_parser, READONLY | NOARG | READEARLY, NULL, | |
+ NULL, NULL, NULL); | |
REGISTER_TUNABLE("buffers_per_context", NULL, TUNABLE_INTEGER, | |
&gbl_buffers_per_context, READONLY | NOZERO, NULL, NULL, NULL, | |
NULL); | |
@@ -184,7 +184,8 @@ REGISTER_TUNABLE("disable_datetime_truncation", | |
NULL, NULL); | |
REGISTER_TUNABLE("disable_direct_writes", "Disables 'enable_direct_writes'", | |
TUNABLE_BOOLEAN, &db->enable_direct_writes, | |
- INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
+ INVERSE_VALUE | READONLY | NOARG | READEARLY, NULL, NULL, NULL, | |
+ NULL); | |
REGISTER_TUNABLE("disable_good_sql_return_codes", | |
"Disables 'enable_good_sql_return_codes'", TUNABLE_BOOLEAN, | |
&gbl_enable_good_sql_return_codes, | |
@@ -262,7 +263,8 @@ REGISTER_TUNABLE("disable_upgrade_ahead", "Sets 'enable_upgrade_ahead' to 0.", | |
INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("disallow_portmux_route", "Disables 'allow_portmux_route'", | |
TUNABLE_BOOLEAN, &gbl_pmux_route_enabled, | |
- INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
+ INVERSE_VALUE | READONLY | NOARG | READEARLY, NULL, NULL, NULL, | |
+ NULL); | |
REGISTER_TUNABLE("dont_abort_on_in_use_rqid", "Disable 'abort_on_in_use_rqid'", | |
TUNABLE_BOOLEAN, &gbl_abort_on_clear_inuse_rqid, | |
INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
@@ -272,7 +274,8 @@ REGISTER_TUNABLE("dont_abort_on_missing_session", | |
INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("dont_forbid_ulonglong", "Disables 'forbid_ulonglong'", | |
TUNABLE_BOOLEAN, &gbl_forbid_ulonglong, | |
- INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
+ INVERSE_VALUE | READONLY | NOARG | READEARLY, NULL, NULL, NULL, | |
+ NULL); | |
REGISTER_TUNABLE("dont_init_with_inplace_updates", | |
"Disables 'init_with_inplace_updates'", TUNABLE_BOOLEAN, | |
&gbl_init_with_ipu, INVERSE_VALUE | READONLY | NOARG, NULL, | |
@@ -287,8 +290,9 @@ REGISTER_TUNABLE("dont_init_with_ondisk_header", | |
NULL, NULL, NULL); | |
REGISTER_TUNABLE("dont_optimize_repdb_truncate", | |
"Disable 'optimize_repdb_truncate'", TUNABLE_BOOLEAN, | |
- &gbl_optimize_truncate_repdb, INVERSE_VALUE | READONLY | NOARG, | |
- NULL, NULL, NULL, NULL); | |
+ &gbl_optimize_truncate_repdb, | |
+ INVERSE_VALUE | READONLY | NOARG | READEARLY, NULL, NULL, NULL, | |
+ NULL); | |
REGISTER_TUNABLE("dont_prefix_foreign_keys", "Disables 'prefix_foreign_keys'", | |
TUNABLE_BOOLEAN, &gbl_fk_allow_prefix_keys, | |
INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
@@ -470,16 +474,16 @@ REGISTER_TUNABLE("fdbtrackhints", NULL, TUNABLE_INTEGER, &gbl_fdb_track_hints, | |
REGISTER_TUNABLE("fkrcode", NULL, TUNABLE_INTEGER, &gbl_fkrcode, | |
READONLY | INTERNAL, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("forbid_ulonglong", "Disallow u_longlong. (Default: on)", | |
- TUNABLE_BOOLEAN, &gbl_forbid_ulonglong, READONLY | NOARG, NULL, | |
- NULL, NULL, NULL); | |
+ TUNABLE_BOOLEAN, &gbl_forbid_ulonglong, | |
+ READONLY | NOARG | READEARLY, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("force_highslot", NULL, TUNABLE_BOOLEAN, &gbl_force_highslot, | |
READONLY | NOARG, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("foreign_db_allow_cross_class", NULL, TUNABLE_BOOLEAN, | |
- &gbl_fdb_allow_cross_classes, READONLY | NOARG, NULL, NULL, | |
- NULL, NULL); | |
+ &gbl_fdb_allow_cross_classes, READONLY | NOARG | READEARLY, | |
+ NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("foreign_db_resolve_local", NULL, TUNABLE_BOOLEAN, | |
- &gbl_fdb_resolve_local, READONLY | NOARG, NULL, NULL, NULL, | |
- NULL); | |
+ &gbl_fdb_resolve_local, READONLY | NOARG | READEARLY, NULL, | |
+ NULL, NULL, NULL); | |
REGISTER_TUNABLE("fullrecovery", "Attempt to run database " | |
"recovery from the beginning of " | |
"available logs. (Default : off)", | |
@@ -501,8 +505,8 @@ REGISTER_TUNABLE("heartbeat_send_time", | |
"Send heartbeats this often. (Default: 5secs)", | |
TUNABLE_INTEGER, &gbl_heartbeat_send, READONLY | NOZERO, NULL, | |
NULL, NULL, NULL); | |
-REGISTER_TUNABLE("hostname", NULL, TUNABLE_STRING, &gbl_mynode, READONLY, NULL, | |
- NULL, hostname_update, NULL); | |
+REGISTER_TUNABLE("hostname", NULL, TUNABLE_STRING, &gbl_mynode, | |
+ READONLY | READEARLY, NULL, NULL, hostname_update, NULL); | |
REGISTER_TUNABLE("incoherent_alarm_time", NULL, TUNABLE_INTEGER, | |
&gbl_incoherent_alarm_time, READONLY, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("incoherent_msg_freq", NULL, TUNABLE_INTEGER, | |
@@ -569,14 +573,14 @@ REGISTER_TUNABLE("largepages", "Enables large pages. (Default: off)", | |
NULL, NULL); | |
REGISTER_TUNABLE("lclpooledbufs", NULL, TUNABLE_INTEGER, &gbl_lclpooled_buffers, | |
READONLY, NULL, NULL, NULL, NULL); | |
-REGISTER_TUNABLE("lk_hash", NULL, TUNABLE_INTEGER, &gbl_lk_hash, READONLY, NULL, | |
- lk_verify, NULL, NULL); | |
-REGISTER_TUNABLE("lk_part", NULL, TUNABLE_INTEGER, &gbl_lk_parts, READONLY, | |
- NULL, lk_verify, NULL, NULL); | |
-REGISTER_TUNABLE("lkr_hash", NULL, TUNABLE_INTEGER, &gbl_lkr_hash, READONLY, | |
- NULL, lk_verify, NULL, NULL); | |
-REGISTER_TUNABLE("lkr_part", NULL, TUNABLE_INTEGER, &gbl_lkr_parts, READONLY, | |
- NULL, lk_verify, NULL, NULL); | |
+REGISTER_TUNABLE("lk_hash", NULL, TUNABLE_INTEGER, &gbl_lk_hash, | |
+ READONLY | READEARLY, NULL, lk_verify, NULL, NULL); | |
+REGISTER_TUNABLE("lk_part", NULL, TUNABLE_INTEGER, &gbl_lk_parts, | |
+ READONLY | READEARLY, NULL, lk_verify, NULL, NULL); | |
+REGISTER_TUNABLE("lkr_hash", NULL, TUNABLE_INTEGER, &gbl_lkr_hash, | |
+ READONLY | READEARLY, NULL, lk_verify, NULL, NULL); | |
+REGISTER_TUNABLE("lkr_part", NULL, TUNABLE_INTEGER, &gbl_lkr_parts, | |
+ READONLY | READEARLY, NULL, lk_verify, NULL, NULL); | |
REGISTER_TUNABLE("lock_conflict_trace", | |
"Dump count of lock conflicts every second. (Default: off)", | |
TUNABLE_BOOLEAN, &gbl_lock_conflict_trace, READONLY | NOARG, | |
@@ -682,7 +686,7 @@ REGISTER_TUNABLE("memstat_autoreport_freq", | |
TUNABLE_INTEGER, &gbl_memstat_freq, READONLY, NULL, NULL, NULL, | |
NULL); | |
REGISTER_TUNABLE("morecolumns", NULL, TUNABLE_INTEGER, &gbl_morecolumns, | |
- READONLY, NULL, NULL, NULL, NULL); | |
+ READONLY | READEARLY, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("move_deadlock_max_attempt", NULL, TUNABLE_INTEGER, | |
&gbl_move_deadlk_max_attempt, READONLY, NULL, NULL, NULL, | |
NULL); | |
@@ -775,7 +779,7 @@ REGISTER_TUNABLE("no_lock_conflict_trace", "Disables 'lock_conflict_trace'", | |
TUNABLE_BOOLEAN, &gbl_lock_conflict_trace, | |
INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("nonames", NULL, TUNABLE_BOOLEAN, &gbl_nonames, | |
- READONLY | NOARG, NULL, NULL, NULL, NULL); | |
+ READONLY | NOARG | READEARLY, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("no_net_explicit_flush_trace", | |
"Disables 'net_explicit_flush_trace'", TUNABLE_BOOLEAN, | |
&explicit_flush_trace, INVERSE_VALUE | READONLY | NOARG, NULL, | |
@@ -830,7 +834,8 @@ REGISTER_TUNABLE("null_blob_fix", NULL, TUNABLE_BOOLEAN, | |
REGISTER_TUNABLE( | |
"nullfkey", | |
"Do not enforce foreign key constraints for null keys. (Default: off)", | |
- TUNABLE_BOOLEAN, &gbl_nullfkey, READONLY | NOARG, NULL, NULL, NULL, NULL); | |
+ TUNABLE_BOOLEAN, &gbl_nullfkey, READONLY | NOARG | READEARLY, NULL, NULL, | |
+ NULL, NULL); | |
/* | |
REGISTER_TUNABLE("nullsort", NULL, TUNABLE_ENUM, | |
&placeholder, READONLY, NULL, NULL, NULL, NULL); | |
@@ -851,7 +856,7 @@ REGISTER_TUNABLE("oldrangexlim", NULL, TUNABLE_BOOLEAN, | |
REGISTER_TUNABLE("optimize_repdb_truncate", | |
"Enables use of optimized repdb truncate code. (Default: on)", | |
TUNABLE_BOOLEAN, &gbl_optimize_truncate_repdb, | |
- READONLY | NOARG, NULL, NULL, NULL, NULL); | |
+ READONLY | NOARG | READEARLY, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("osql_bkoff_netsend", NULL, TUNABLE_INTEGER, | |
&gbl_osql_bkoff_netsend, READONLY, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("osql_bkoff_netsend_lmt", NULL, TUNABLE_INTEGER, | |
@@ -919,9 +924,10 @@ REGISTER_TUNABLE("penaltyincpercent", NULL, TUNABLE_INTEGER, | |
REGISTER_TUNABLE("perfect_ckp", NULL, TUNABLE_INTEGER, &gbl_use_perfect_ckp, | |
READONLY | NOARG, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("portmux_bind_path", NULL, TUNABLE_STRING, | |
- &gbl_portmux_unix_socket, READONLY, NULL, NULL, NULL, NULL); | |
-REGISTER_TUNABLE("portmux_port", NULL, TUNABLE_INTEGER, &portmux_port, READONLY, | |
- NULL, NULL, NULL, NULL); | |
+ &gbl_portmux_unix_socket, READONLY | READEARLY, NULL, NULL, | |
+ NULL, NULL); | |
+REGISTER_TUNABLE("portmux_port", NULL, TUNABLE_INTEGER, &portmux_port, | |
+ READONLY | READEARLY, NULL, NULL, NULL, NULL); | |
REGISTER_TUNABLE("prefaulthelper_blockops", NULL, TUNABLE_INTEGER, | |
&gbl_prefaulthelper_blockops, READONLY, NULL, NULL, NULL, | |
NULL); | |
@@ -1156,7 +1162,8 @@ REGISTER_TUNABLE("use_llmeta", NULL, TUNABLE_INTEGER, | |
&gbl_use_llmeta, READONLY, NULL, NULL, NULL, NULL); | |
*/ | |
REGISTER_TUNABLE("usenames", NULL, TUNABLE_BOOLEAN, &gbl_nonames, | |
- INVERSE_VALUE | READONLY | NOARG, NULL, NULL, NULL, NULL); | |
+ INVERSE_VALUE | READONLY | NOARG | READEARLY, NULL, NULL, NULL, | |
+ NULL); | |
REGISTER_TUNABLE("use_node_priority", | |
"Sets node priority for the db. (Default: off)", | |
TUNABLE_BOOLEAN, &gbl_use_node_pri, READONLY | NOARG, NULL, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment