Skip to content

Commit 07e958f

Browse files
committed
Reduce physrep-sql against the metadb
Signed-off-by: mhannum <mhannum@bloomberg.net>
1 parent 087ef4a commit 07e958f

File tree

13 files changed

+24
-78
lines changed

13 files changed

+24
-78
lines changed

db/db_tunables.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ extern int gbl_physrep_update_registry_interval;
522522
extern int gbl_physrep_i_am_metadb;
523523
extern int gbl_physrep_keepalive_v2;
524524
extern int gbl_physrep_keepalive_freq_sec;
525+
extern int gbl_physrep_slow_replicant_check_freq_sec;
525526
extern int gbl_physrep_max_candidates;
526527
extern int gbl_physrep_reconnect_penalty;
527528
extern int gbl_physrep_reconnect_interval;

db/db_tunables.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,19 +1821,15 @@ REGISTER_TUNABLE("tranlog_incoherent_timeout", "Timeout in seconds for incoheren
18211821
TUNABLE_INTEGER, &gbl_tranlog_incoherent_timeout, 0, NULL, NULL, NULL, NULL);
18221822
REGISTER_TUNABLE("tranlog_maxpoll", "Tranlog timeout in seconds for blocking poll. (Default: 60)", TUNABLE_INTEGER,
18231823
&gbl_tranlog_maxpoll, 0, NULL, NULL, NULL, NULL);
1824-
REGISTER_TUNABLE("physrep_check_minlog_freq_sec", "Check the minimum log number to keep this often. (Default: 10)",
1825-
TUNABLE_INTEGER, &gbl_physrep_check_minlog_freq_sec, 0, NULL, NULL, NULL, NULL);
18261824
REGISTER_TUNABLE("physrep_debug", "Print extended physrep trace. (Default: off)", TUNABLE_BOOLEAN, &gbl_physrep_debug,
18271825
0, NULL, NULL, NULL, NULL);
18281826
REGISTER_TUNABLE("physrep_exit_on_invalid_logstream", "Exit physreps on invalid logstream. (Default: off)",
18291827
TUNABLE_BOOLEAN, &gbl_physrep_exit_on_invalid_logstream, 0, NULL, NULL, NULL, NULL);
18301828
REGISTER_TUNABLE("physrep_fanout",
18311829
"Maximum number of physical replicants that a node can service (Default: 8)",
18321830
TUNABLE_INTEGER, &gbl_physrep_fanout, 0, NULL, NULL, NULL, NULL);
1833-
REGISTER_TUNABLE("physrep_hung_replicant_check_freq_sec",
1834-
"Check for hung physical replicant this often. (Default: 10)",
1835-
TUNABLE_INTEGER, &gbl_physrep_hung_replicant_check_freq_sec, 0, NULL,
1836-
NULL, NULL, NULL);
1831+
REGISTER_TUNABLE("physrep_hung_replicant_check_freq_sec", "Check for hung physical replicant this often. (Default: 60)",
1832+
TUNABLE_INTEGER, &gbl_physrep_hung_replicant_check_freq_sec, 0, NULL, NULL, NULL, NULL);
18371833
REGISTER_TUNABLE("physrep_hung_replicant_threshold",
18381834
"Report if the physical replicant has been inactive for this duration. (Default: 60)",
18391835
TUNABLE_INTEGER, &gbl_physrep_hung_replicant_threshold, 0, NULL,
@@ -1856,13 +1852,14 @@ REGISTER_TUNABLE("physrep_i_am_metadb", "I am physical replication metadb (Defau
18561852
REGISTER_TUNABLE("physrep_keepalive_v2", "Use version 2 of keepalive which includes first lsn. (Default: off)",
18571853
TUNABLE_BOOLEAN, &gbl_physrep_keepalive_v2, 0, NULL, NULL, NULL, NULL);
18581854
REGISTER_TUNABLE("physrep_keepalive_freq_sec",
1859-
"Periodically send lsn to source node after this interval. (Default: 10)", TUNABLE_INTEGER,
1855+
"Periodically send lsn to source node after this interval. (Default: 60)", TUNABLE_INTEGER,
18601856
&gbl_physrep_keepalive_freq_sec, 0, NULL, NULL, NULL, NULL);
1857+
REGISTER_TUNABLE("physrep_slow_replicant_check_freq_sec", "Check for slow physical replicant this often. (Default: 60)",
1858+
TUNABLE_INTEGER, &gbl_physrep_slow_replicant_check_freq_sec, 0, NULL, NULL, NULL, NULL);
18611859
REGISTER_TUNABLE("physrep_max_candidates",
18621860
"Maximum number of candidates that should be returned to a "
18631861
"new physical replicant during registration. (Default: 6)",
1864-
TUNABLE_INTEGER, &gbl_physrep_max_candidates, 0, NULL,
1865-
NULL, NULL, NULL);
1862+
TUNABLE_INTEGER, &gbl_physrep_max_candidates, 0, NULL, NULL, NULL, NULL);
18661863
REGISTER_TUNABLE("physrep_metadb_host", "List of physical replication metadb cluster hosts.", TUNABLE_STRING,
18671864
&gbl_physrep_metadb_host, READONLY, NULL, NULL, NULL, NULL);
18681865
REGISTER_TUNABLE("physrep_metadb_name", "Physical replication metadb cluster name.",

db/phys_rep.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ int gbl_physrep_fanout = 8;
6767
int gbl_physrep_max_candidates = 6;
6868
int gbl_physrep_max_pending_replicants = 10;
6969
int gbl_deferred_phys_flag = 0;
70-
int gbl_physrep_source_nodes_refresh_freq_sec = 10;
71-
int gbl_physrep_slow_replicant_check_freq_sec = 10;
72-
int gbl_physrep_keepalive_freq_sec = 10;
73-
int gbl_physrep_check_minlog_freq_sec = 10;
74-
int gbl_physrep_hung_replicant_check_freq_sec = 10;
70+
int gbl_physrep_slow_replicant_check_freq_sec = 60;
71+
int gbl_physrep_keepalive_freq_sec = 60;
72+
int gbl_physrep_hung_replicant_check_freq_sec = 60;
73+
int gbl_physrep_check_minlog_freq_sec = 600;
7574
int gbl_physrep_hung_replicant_threshold = 60;
7675
int gbl_physrep_revconn_check_interval = 60;
7776
int gbl_physrep_update_registry_interval = 60;
@@ -1107,27 +1106,10 @@ int gbl_physrep_keepalive_v2 = 0;
11071106

11081107
static int send_keepalive_int(cdb2_hndl_tp *metadb)
11091108
{
1110-
int rc = 0, use_v2 = 0;
1109+
int rc = 0, use_v2 = gbl_physrep_keepalive_v2;
11111110
char cmd[600];
11121111
LOG_INFO info;
11131112

1114-
/* TODO: remove after v2 enabled & new-schema is everywhere */
1115-
if (gbl_physrep_keepalive_v2) {
1116-
rc = snprintf(
1117-
cmd, sizeof(cmd),
1118-
"select count(*) from comdb2_columns where tablename='comdb2_physreps' and columnname='firstfile'");
1119-
ATOMIC_ADD64(gbl_physrep_metadb_sql_count, 1);
1120-
rc = cdb2_run_statement(metadb, cmd);
1121-
if (rc != CDB2_OK) {
1122-
physrep_logmsg(LOGMSG_ERROR, "%s:%d Failed to execute cmd %s (rc: %d)\n", __func__, __LINE__, cmd, rc);
1123-
return rc;
1124-
}
1125-
if (cdb2_next_record(metadb) == CDB2_OK) {
1126-
int64_t val = *(int64_t *)cdb2_column_value(metadb, 0);
1127-
use_v2 = (val != 0) ? 1 : 0;
1128-
}
1129-
}
1130-
11311113
info = get_last_lsn(thedb->bdb_env);
11321114
if (use_v2) {
11331115
LOG_INFO first_info;

lua/lib/physrep_get_reverse_hosts.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
local function main(dbname, hostname)
66
db:begin()
77

8-
-- Check whether 'comdb2_physrep_sources' table exists
9-
local rs, rc = db:exec("SELECT count(*)=1 AS cnt FROM comdb2_tables WHERE tablename = 'comdb2_physrep_sources'")
10-
local row = rs:fetch()
11-
if row.cnt == 0 then
12-
db:commit()
13-
return
14-
end
15-
168
local rs, rc = db:exec("SELECT dbname, host FROM comdb2_physrep_sources WHERE " ..
179
"source_dbname = '" .. dbname .. "' AND source_host = '" .. hostname .. "'")
1810
local row = rs:fetch()

lua/lib/physrep_get_reverse_hosts_v2.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
local function main(dbname, hostname)
66
db:begin()
77

8-
-- Check whether 'comdb2_physrep_sources' table exists
9-
local rs, rc = db:exec("SELECT count(*)=1 AS cnt FROM comdb2_tables WHERE tablename = 'comdb2_physrep_sources'")
10-
local row = rs:fetch()
11-
if row.cnt == 0 then
12-
db:commit()
13-
return
14-
end
15-
168
local rs, rc = db:exec("SELECT dbname, host FROM comdb2_physrep_sources WHERE " ..
179
"source_dbname = '" .. dbname .. "' AND source_host = '" .. hostname .. "'")
1810
local row = rs:fetch()

lua/lib/physrep_get_revhosts_v2.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
local function main(dbname, hostname, tier, cluster)
66
db:begin()
77

8-
-- Check whether 'comdb2_physrep_sources' table exists
9-
local rs, rc = db:exec("SELECT count(*)=1 AS cnt FROM comdb2_tables WHERE tablename = 'comdb2_physrep_sources'")
10-
local row = rs:fetch()
11-
if row.cnt == 0 then
12-
db:commit()
13-
return
14-
end
15-
168
local sql = ("SELECT dbname, host FROM comdb2_physrep_sources WHERE " ..
179
"source_dbname = '" .. dbname .. "' AND ( source_host = '" .. hostname ..
1810
"' OR source_host = '" .. tier ..

lua/lib/physrep_should_wait_for_con.lua

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010
local function main(dbname, hostname)
1111
db:begin()
1212

13-
local rs, row = db:exec("SELECT count(*)=1 AS cnt FROM comdb2_tables WHERE tablename = 'comdb2_physrep_sources'")
14-
local row = rs:fetch()
15-
16-
if row.cnt == 0 then
17-
db:emit(row)
18-
db:commit()
19-
return
20-
end
21-
2213
local rs, row = db:exec("SELECT count(*) as cnt FROM comdb2_physrep_sources " ..
2314
" WHERE dbname = '" .. dbname .. "' AND " ..
2415
" host LIKE '" .. hostname .. "'")

lua/lib/physrep_shouldwait_v2.lua

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010
local function main(dbname, hostname, tier, cluster)
1111
db:begin()
1212

13-
local rs, row = db:exec("SELECT count(*)=1 AS cnt FROM comdb2_tables WHERE tablename = 'comdb2_physrep_sources'")
14-
local row = rs:fetch()
15-
16-
if row.cnt == 0 then
17-
db:emit(row)
18-
db:commit()
19-
return
20-
end
21-
2213
local sql = ("SELECT count(*) as cnt from comdb2_physrep_sources " ..
2314
" WHERE dbname = '" .. dbname .. "' AND " ..
2415
" ( host LIKE '" .. hostname .. "' OR " ..
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
physrep_keepalive_v2 1

tests/phys_rep_tiered.test/lrl.options

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ forbid_remote_admin 0
1010
ctrace_dbdir 1
1111
allow_lua_print 1
1212
reverse_hosts_v2 1
13-
physrep_keepalive_v2 1
13+
physrep_keepalive_v2 0
1414
enable_snapshot_isolation
1515

1616
# Reproduced 'incoherent-physrep' bug with this removed.

0 commit comments

Comments
 (0)