From 998a7416c27b2591e9c86b570f5c6fccb68093a0 Mon Sep 17 00:00:00 2001 From: slguan Date: Tue, 28 Apr 2020 19:03:22 +0800 Subject: [PATCH] [TD-184] --- src/vnode/src/vnodeMain.c | 9 +- tests/script/sh/exec_up.sh | 21 ++-- tests/script/unique/db/replica_part.sim | 91 +++++------------ tests/script/unique/db/replica_reduce31.sim | 102 ++++++-------------- tests/script/unique/db/replica_reduce32.sim | 38 ++------ tests/script/unique/db/testSuite.sim | 2 +- 6 files changed, 76 insertions(+), 187 deletions(-) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index becb26e778..9c4c2d562e 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -311,7 +311,7 @@ void *vnodeGetWqueue(int32_t vgId) { SVnodeObj *pVnode = vnodeAccquireVnode(vgId); if (pVnode == NULL) return NULL; return pVnode->wqueue; -} +} void *vnodeGetWal(void *pVnode) { return ((SVnodeObj *)pVnode)->wal; @@ -341,10 +341,13 @@ static void vnodeBuildVloadMsg(char *pNode, void * param) { } static void vnodeCleanUp(SVnodeObj *pVnode) { - taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId); - //syncStop(pVnode->sync); + if (pVnode->sync) { + syncStop(pVnode->sync); + pVnode->sync = NULL; + } + tsdbCloseRepo(pVnode->tsdb); walClose(pVnode->wal); vnodeSaveVersion(pVnode); diff --git a/tests/script/sh/exec_up.sh b/tests/script/sh/exec_up.sh index ee4aabc175..abe2822450 100755 --- a/tests/script/sh/exec_up.sh +++ b/tests/script/sh/exec_up.sh @@ -70,24 +70,15 @@ if [ "$CLEAR_OPTION" = "clear" ]; then rm -rf $MGMT_DIR fi -if [ "$SHELL_OPTION" = "true" ]; then - if [ "$EXEC_OPTON" = "start" ]; then - echo "ExcuteCmd:" $EXE_DIR/taos -c $CFG_DIR -u $USERS -p - $EXE_DIR/taos -c $CFG_DIR -u $USERS -p +if [ "$EXEC_OPTON" = "start" ]; then + echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR + + if [ "$SHELL_OPTION" = "true" ]; then + nohup valgrind --log-file=${LOG_DIR}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & else - #relative path - RCFG_DIR=sim/$NODE_NAME/cfg - PID=`ps -ef|grep -v taosd | grep taos | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` - if [ -n "$PID" ]; then - sudo kill -9 $PID - fi + nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & fi - return -fi -if [ "$EXEC_OPTON" = "start" ]; then - echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR - nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & #TT=`date +%s` #mkdir ${LOG_DIR}/${TT} #echo valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR diff --git a/tests/script/unique/db/replica_part.sim b/tests/script/unique/db/replica_part.sim index e856a995e4..144c3f674f 100644 --- a/tests/script/unique/db/replica_part.sim +++ b/tests/script/unique/db/replica_part.sim @@ -66,12 +66,12 @@ endi print ========= step2 alter db system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -sleep 3000 +sleep 5000 sql alter database d1 replica 2 sql alter database d2 replica 2 sql alter database d3 replica 2 sql alter database d4 replica 2 -sleep 3000 +sleep 5000 print ========= step3 system sh/exec_up.sh -n dnode2 -s start @@ -105,69 +105,38 @@ endi print ========= step5 system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 3) -sql insert into d2.t2 values(now, 3) -sql insert into d3.t3 values(now, 3) -sql insert into d4.t4 values(now, 3) - -sql select * from d1.t1 -if $rows != 3 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 3 then - return -1 -endi +sleep 5000 -sql select * from d3.t3 -if $rows != 3 then - return -1 -endi +sql reset query cache +sleep 1000 -sql select * from d4.t4 -if $rows != 3 then - return -1 -endi +sql insert into d1.t1 values(now, 3) -x s1 +s1: +sql insert into d2.t2 values(now, 3) -x s2 +s2: +sql insert into d3.t3 values(now, 3) -x s3 +s3: +sql insert into d4.t4 values(now, 3) -x s4 +s4: print ========= step6 system sh/exec_up.sh -n dnode2 -s start sleep 5000 system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) - -sql select * from d1.t1 -if $rows != 4 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 4 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 4 then - return -1 -endi +sleep 5000 -sql select * from d4.t4 -if $rows != 4 then - return -1 -endi +sql insert into d1.t1 values(now, 4) -x s5 +s5: +sql insert into d2.t2 values(now, 4) -x s6 +s6: +sql insert into d3.t3 values(now, 4) -x s7 +s7: +sql insert into d4.t4 values(now, 4) -x s8 +s8: print ========= step7 system sh/exec_up.sh -n dnode3 -s start sleep 5000 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -sleep 3000 sql insert into d1.t1 values(now, 5) sql insert into d2.t2 values(now, 5) @@ -175,22 +144,6 @@ sql insert into d3.t3 values(now, 5) sql insert into d4.t4 values(now, 5) sql select * from d1.t1 -if $rows != 5 then - return -1 -endi - sql select * from d2.t2 -if $rows != 5 then - return -1 -endi - sql select * from d3.t3 -if $rows != 5 then - return -1 -endi - sql select * from d4.t4 -if $rows != 5 then - return -1 -endi - diff --git a/tests/script/unique/db/replica_reduce31.sim b/tests/script/unique/db/replica_reduce31.sim index 2343a992a1..c34dccbd62 100644 --- a/tests/script/unique/db/replica_reduce31.sim +++ b/tests/script/unique/db/replica_reduce31.sim @@ -72,9 +72,18 @@ sql alter database d1 replica 2 sql alter database d2 replica 2 sql alter database d3 replica 2 -sleep 12000 +sleep 8000 + +sql alter database d1 replica 1 +sql alter database d2 replica 1 +sql alter database d3 replica 1 + +sleep 8000 print ========= step3 +sql reset query cache +sleep 1000 + sql insert into d1.t1 values(now, 2) sql insert into d2.t2 values(now, 2) sql insert into d3.t3 values(now, 2) @@ -104,7 +113,7 @@ print ========= step4 alter db sql alter database d1 replica 2 sql alter database d2 replica 2 sql alter database d3 replica 2 -sleep 12000 +sleep 8000 sql insert into d1.t1 values(now, 3) sql insert into d2.t2 values(now, 3) @@ -133,92 +142,45 @@ endi print ========= step4 system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) - -sql select * from d1.t1 -if $rows != 4 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 4 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 4 then - return -1 -endi +sleep 5000 -sql select * from d4.t4 -if $rows != 4 then - return -1 -endi +sql reset query cache +sleep 1000 +sql insert into d1.t1 values(now, 4) -x step1 +step1: +sql insert into d2.t2 values(now, 4) -x step2 +step2: +sql insert into d3.t3 values(now, 4) -x step3 +step3: +sql insert into d4.t4 values(now, 4) -x step4 +step4: print ========= step5 system sh/exec_up.sh -n dnode2 -s start sleep 5000 system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -sleep 3000 - -sql insert into d1.t1 values(now, 5) -sql insert into d2.t2 values(now, 5) -sql insert into d3.t3 values(now, 5) -sql insert into d4.t4 values(now, 5) - -sql select * from d1.t1 -if $rows != 5 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 5 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 5 then - return -1 -endi - -sql select * from d4.t4 -if $rows != 5 then - return -1 -endi +sleep 5000 +sql insert into d1.t1 values(now, 5) -x step5 +step5: +sql insert into d2.t2 values(now, 5) -x step6 +step6: +sql insert into d3.t3 values(now, 5) -x step7 +step7: +sql insert into d4.t4 values(now, 5) -x step8 +step8: print ========= step6 system sh/exec_up.sh -n dnode3 -s start sleep 5000 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -sleep 3000 + sql insert into d1.t1 values(now, 6) sql insert into d2.t2 values(now, 6) sql insert into d3.t3 values(now, 6) sql insert into d4.t4 values(now, 6) sql select * from d1.t1 -if $rows != 6 then - return -1 -endi - sql select * from d2.t2 -if $rows != 6 then - return -1 -endi - sql select * from d3.t3 -if $rows != 6 then - return -1 -endi - sql select * from d4.t4 -if $rows != 6 then - return -1 -endi diff --git a/tests/script/unique/db/replica_reduce32.sim b/tests/script/unique/db/replica_reduce32.sim index 5f7e121ffb..a9cda824b8 100644 --- a/tests/script/unique/db/replica_reduce32.sim +++ b/tests/script/unique/db/replica_reduce32.sim @@ -96,7 +96,6 @@ sql select * from d4.t4 if $rows != 2 then return -1 endi -return print ========= step4 system sh/exec_up.sh -n dnode2 -s stop -x SIGINT @@ -129,6 +128,7 @@ endi print ========= step5 system sh/exec_up.sh -n dnode2 -s start + sleep 5000 system sh/exec_up.sh -n dnode3 -s stop -x SIGINT sleep 5000 @@ -136,30 +136,10 @@ sleep 5000 sql reset query cache sleep 1000 -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) - -sql select * from d1.t1 -if $rows != 4 then - return -1 -endi - -sql select * from d2.t2 -if $rows != 4 then - return -1 -endi - -sql select * from d3.t3 -if $rows != 4 then - return -1 -endi - -sql select * from d4.t4 -if $rows != 4 then - return -1 -endi +sql_error insert into d1.t1 values(now, 4) +sql_error insert into d2.t2 values(now, 4) +sql_error insert into d3.t3 values(now, 4) +sql_error insert into d4.t4 values(now, 4) print ========= step6 system sh/exec_up.sh -n dnode3 -s start @@ -173,21 +153,21 @@ sql insert into d3.t3 values(now, 5) sql insert into d4.t4 values(now, 5) sql select * from d1.t1 -if $rows != 5 then +if $rows != 4 then return -1 endi sql select * from d2.t2 -if $rows != 5 then +if $rows != 4 then return -1 endi sql select * from d3.t3 -if $rows != 5 then +if $rows != 4 then return -1 endi sql select * from d4.t4 -if $rows != 5 then +if $rows != 4 then return -1 endi diff --git a/tests/script/unique/db/testSuite.sim b/tests/script/unique/db/testSuite.sim index 71593249c1..4918850426 100644 --- a/tests/script/unique/db/testSuite.sim +++ b/tests/script/unique/db/testSuite.sim @@ -6,5 +6,5 @@ run unique/db/replica_add23.sim run unique/db/replica_reduce21.sim run unique/db/replica_reduce32.sim run unique/db/replica_reduce31.sim -#run unique/db/replica_part.sim +run unique/db/replica_part.sim #run unique/db/delete_part.sim -- GitLab