From 42a44bcbd30fd452e21f2008030387477752ce23 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 8 Sep 2020 09:23:06 +0000 Subject: [PATCH] TD-1363 Ensure the sync of mnode not interrupted --- src/sync/src/syncMain.c | 6 +- tests/script/jenkins/basic.txt | 1 + tests/script/unique/cluster/vgroup100.sim | 127 ++++++++++++++++++++++ 3 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 tests/script/unique/cluster/vgroup100.sim diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index b92ef4cf26..da40160bc1 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -797,9 +797,11 @@ static void syncRecoverFromMaster(SSyncPeer *pPeer) { } taosTmrStopA(&pPeer->timer); - if (tsSyncNum >= tsMaxSyncNum) { + + // Ensure the sync of mnode not interrupted + if (pNode->vgId != 1 && tsSyncNum >= tsMaxSyncNum) { sInfo("%s, %d syncs are in process, try later", pPeer->id, tsSyncNum); - taosTmrReset(syncTryRecoverFromMaster, 500 + (pNode->vgId*10)%200, pPeer, syncTmrCtrl, &pPeer->timer); + taosTmrReset(syncTryRecoverFromMaster, 500 + (pNode->vgId * 10) % 200, pPeer, syncTmrCtrl, &pPeer->timer); return; } diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 88a844333b..063d11bd9d 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -253,6 +253,7 @@ cd ../../../debug; make ./test.sh -f unique/cluster/balance2.sim ./test.sh -f unique/cluster/balance3.sim ./test.sh -f unique/cluster/cache.sim +./test.sh -f unique/cluster/vgroup100.sim ./test.sh -f unique/column/replica3.sim diff --git a/tests/script/unique/cluster/vgroup100.sim b/tests/script/unique/cluster/vgroup100.sim new file mode 100644 index 0000000000..cddb38cefd --- /dev/null +++ b/tests/script/unique/cluster/vgroup100.sim @@ -0,0 +1,127 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c maxTables -v 4 +system sh/cfg.sh -n dnode2 -c maxTables -v 4 +system sh/cfg.sh -n dnode3 -c maxTables -v 4 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 + +print ============================== step1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============================== step2 +print ========= start dnode2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +sleep 5000 +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 + +print $dnode1Role +print $dnode2Role +print $dnode3Role + +print ============================== step3 +$count = 2 +while $count < 102 + $db = d . $count + $tb = $db . .t + sql create database $db replica 3 cache 1 blocks 3 + sql create table $tb (ts timestamp, i int) + sql insert into $tb values(now, 1) + $count = $count + 1 + print insert into $tb values(now, 1) ==> finished +endw + +print ============================== step4 + +$count = 2 +while $count < 102 + $db = d . $count + $tb = $db . .t + sql select * from $tb + if $rows != 1 then + print select * from $tb + return -1 + endi + $count = $count + 1 + print select * from $tb ==> rows: $rows +endw + +print ============================== step5 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 5000 + +print ============================== step6 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ============================== step7 + +$x = 0 +show7: + $x = $x + 1 + sleep 2000 + if $x == 50 then + return -1 + endi + +sql show mnodes -x show7 +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +if $dnode1Role != master then + goto show7 +endi +if $dnode2Role != slave then + goto show7 +endi +if $dnode2Role != slave then + goto show7 +endi + +print ============================== step8 +$x = 0 +show8: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi + +$count = 2 +while $count < 102 + $db = d . $count + $tb = $db . .t + sql select * from $tb + if $rows != 1 then + print select * from $tb + goto show8 + endi + $count = $count + 1 + print select * from $tb ==> rows: $rows +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file -- GitLab