@@ -1264,6 +1264,128 @@ function verify_log_cursor_gen()
12641264 done
12651265}
12661266
1267+ function select_from_master()
1268+ {
1269+ local dbname=$1
1270+ local node=$2
1271+ local timeout=$3
1272+ local end=$(( $(date +% s) + timeout ))
1273+
1274+ while [[ $( date +%s) -lt $end ]]; do
1275+ $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $dbname --host $node " select comdb2_host()" > /dev/null 2>&1
1276+ done
1277+ }
1278+
1279+ # Physrep masters and standalone nodes should never return 'incoherent'
1280+ function incoherent_master()
1281+ {
1282+ local physrep_master=" "
1283+ local name=" "
1284+ local node=" "
1285+ local logfile=" "
1286+ local cnt=" "
1287+ local timeout=60
1288+ local foundbad=0
1289+ local beforecnt=0
1290+ local aftercnt=0
1291+ local pids=()
1292+
1293+ echo " == Verifying master/standalone does not return incoherent"
1294+
1295+ echo " Set default-timeout to 5 seconds on all nodes"
1296+ for node in $CLUSTER ; do
1297+ $CDB2SQL_EXE $CDB2_OPTIONS $DBNAME --host $node " put tunable tranlog_default_timeout 5"
1298+ name=" ${REPL_DBNAME_PREFIX} _${node} "
1299+ $CDB2SQL_EXE $CDB2_OPTIONS $name --host $node " put tunable tranlog_default_timeout 5"
1300+ $CDB2SQL_EXE $CDB2_OPTIONS $REPL_CLUS_DBNAME --host $node " put tunable tranlog_default_timeout 5"
1301+ done
1302+
1303+ $CDB2SQL_EXE $CDB2_OPTIONS $DBNAME default " create table xxx(a int)"
1304+
1305+ physrep_master=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $REPL_CLUS_DBNAME --host $firstNode " select host from comdb2_cluster where is_master='Y'" )
1306+
1307+ # Verify that each physrep has this table
1308+ for node in $CLUSTER ; do
1309+ name=" ${REPL_DBNAME_PREFIX} _${node} "
1310+ cnt=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $name --host $node " select count(*) from comdb2_tables where tablename='xxx'" )
1311+ while [[ " $cnt " -ne " 1" ]]; do
1312+ sleep 1
1313+ cnt=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $name --host $node " select count(*) from comdb2_tables where tablename='xxx'" )
1314+ done
1315+
1316+ cnt=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $REPL_CLUS_DBNAME --host $node " select count(*) from comdb2_tables where tablename='xxx'" )
1317+ while [[ " $cnt " -ne " 1" ]]; do
1318+ sleep 1
1319+ cnt=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $REPL_CLUS_DBNAME --host $node " select count(*) from comdb2_tables where tablename='xxx'" )
1320+ done
1321+ done
1322+
1323+ echo " Getting before-count from current clustered physrep master"
1324+ logfile=$TESTDIR /logs/${REPL_CLUS_DBNAME} .${physrep_master} .log
1325+ beforecnt=$( egrep " new query on incoherent node" $logfile | wc -l)
1326+
1327+ echo " Spawning select-from-master threads"
1328+ select_from_master $REPL_CLUS_DBNAME $physrep_master $timeout &
1329+ pids+=($! )
1330+
1331+ for node in $CLUSTER ; do
1332+ name=" ${REPL_DBNAME_PREFIX} _${node} "
1333+ select_from_master $name $node $timeout &
1334+ pids+=($! )
1335+ done
1336+
1337+ echo " Waiting on all spawned pids"
1338+ for p in " ${pids[@]} " ; do
1339+ wait $p
1340+ done
1341+
1342+ echo " Checking for incoherent trace in output files"
1343+ for node in $CLUSTER ; do
1344+ name=" ${REPL_DBNAME_PREFIX} _${node} "
1345+ logfile=$TESTDIR /logs/${name} .log
1346+ egrep " new query on incoherent node" $logfile > /dev/null 2>&1
1347+ if [[ $? -eq 0 ]]; then
1348+ echo " Found incoherent trace in $logfile "
1349+ foundbad=1
1350+ fi
1351+ done
1352+
1353+ logfile=$TESTDIR /logs/${REPL_CLUS_DBNAME} .${physrep_master} .log
1354+ aftercnt=$( egrep " new query on incoherent node" $logfile | wc -l)
1355+ if [[ " $beforecnt " -ne " $aftercnt " ]]; then
1356+ echo " Found additional incoherent in $logfile "
1357+ foundbad=1
1358+ fi
1359+
1360+ [[ " $foundbad " -eq 1 ]] && cleanFailExit " incoherent_master test failed"
1361+
1362+ echo " Drop table xxx"
1363+ $CDB2SQL_EXE ${CDB2_OPTIONS} $DBNAME default " drop table xxx"
1364+
1365+ # Verify that each physrep has dropped this table
1366+ for node in $CLUSTER ; do
1367+ name=" ${REPL_DBNAME_PREFIX} _${node} "
1368+ cnt=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $name --host $node " select count(*) from comdb2_tables where tablename='xxx'" )
1369+ while [[ " $cnt " -ne " 0" ]]; do
1370+ sleep 1
1371+ cnt=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $name --host $node " select count(*) from comdb2_tables where tablename='xxx'" )
1372+ done
1373+ cnt=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $REPL_CLUS_DBNAME --host $node " select count(*) from comdb2_tables where tablename='xxx'" )
1374+ while [[ " $cnt " -ne " 0" ]]; do
1375+ sleep 1
1376+ cnt=$( $CDB2SQL_EXE --tabs ${CDB2_OPTIONS} $REPL_CLUS_DBNAME --host $node " select count(*) from comdb2_tables where tablename='xxx'" )
1377+ done
1378+ done
1379+
1380+ echo " Set default-timeout back to 30 seconds on all nodes"
1381+ for node in $CLUSTER ; do
1382+ $CDB2SQL_EXE $CDB2_OPTIONS $DBNAME --host $node " put tunable tranlog_default_timeout 30"
1383+ name=" ${REPL_DBNAME_PREFIX} _${node} "
1384+ $CDB2SQL_EXE $CDB2_OPTIONS $name --host $node " put tunable tranlog_default_timeout 30"
1385+ $CDB2SQL_EXE $CDB2_OPTIONS $REPL_CLUS_DBNAME --host $node " put tunable tranlog_default_timeout 30"
1386+ done
1387+ }
1388+
12671389function revconn_latency()
12681390{
12691391 typeset now=$( date +%s)
@@ -2241,8 +2363,6 @@ function verify_non_ignored_reptype
22412363 [[ -n " $ignored " ]] && cleanFailExit " Found ignored rep-messages after incoherent recovery: $ignored "
22422364}
22432365
2244- # egrep "Ignoring rp->gen" * | egrep "rectype=2\>|rectype=11\>|rectype=10\>"
2245-
22462366function announce
22472367{
22482368 typeset text=$1
@@ -2402,6 +2522,11 @@ function run_tests
24022522 verify_alt_metadb_system_table
24032523 testcase_finish $testcase
24042524
2525+ testcase=" incoherent_master"
2526+ testcase_preamble $testcase
2527+ incoherent_master
2528+ testcase_finish $testcase
2529+
24052530 testcase=" physrep_allowed_source"
24062531 testcase_preamble $testcase
24072532 physrep_allowed_source
@@ -2410,10 +2535,9 @@ function run_tests
24102535
24112536function run_one_test
24122537{
2413- physrep_allowed_source
2538+ incoherent_master
24142539}
24152540
2416- # run_one_test
24172541run_tests
24182542cleanup
24192543
0 commit comments