diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 463f5dde478c8e126a579d8db6540c24deca5786..c3ae8b5ab1cbb16233a4a89173ada241710c9108 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -74,6 +74,7 @@ static int32_t mgmtDnodeActionDelete(SSdbOper *pOper) { SDnodeObj *pDnode = pOper->pObj; #ifndef _SYNC + //TODO: drop dnode local mgmtDropAllDnodeVgroups(pDnode); #endif mgmtDropMnodeLocal(pDnode->dnodeId); diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index bd4f022bc17c16c6a3d01efe632f6f4195805814..3e3b16fa9da9984c0894df3a6087161b8b440497 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -546,6 +546,7 @@ static void *mgmtGetSuperTableByUid(uint64_t uid) { pIter = mgmtGetNextSuperTable(pIter, &pStable); if (pStable == NULL) break; if (pStable->uid == uid) { + sdbFreeIter(pIter); return pStable; } mgmtDecTableRef(pStable); @@ -1459,15 +1460,15 @@ static void mgmtProcessCreateChildTableMsg(SQueuedMsg *pMsg) { return; } - int32_t sid = taosAllocateId(pVgroup->idPool); - if (sid <= 0) { - mTrace("tables:%s, no enough sid in vgId:%d", pCreate->tableId, pVgroup->vgId); - mgmtCreateVgroup(mgmtCloneQueuedMsg(pMsg), pMsg->pDb); - return; - } - if (pMsg->retry == 0) { if (pMsg->pTable == NULL) { + int32_t sid = taosAllocateId(pVgroup->idPool); + if (sid <= 0) { + mTrace("tables:%s, no enough sid in vgId:%d", pCreate->tableId, pVgroup->vgId); + mgmtCreateVgroup(mgmtCloneQueuedMsg(pMsg), pMsg->pDb); + return; + } + pMsg->pTable = (STableObj *)mgmtDoCreateChildTable(pCreate, pVgroup, sid); mgmtIncTableRef(pMsg->pTable); } diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index f8447a31fd06faf6d8dcb76286fc611c72f80b4c..1416ed5f58d41ec2485af9145606900fe5506ddb 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -666,7 +666,6 @@ static SMDDropVnodeMsg *mgmtBuildDropVnodeMsg(int32_t vgId) { } void mgmtSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle) { - mTrace("vgId:%d, send drop vnode msg, ahandle:%p", vgId, ahandle); SMDDropVnodeMsg *pDrop = mgmtBuildDropVnodeMsg(vgId); SRpcMsg rpcMsg = { .handle = ahandle, @@ -682,6 +681,7 @@ static void mgmtSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) { mTrace("vgId:%d, send drop all vnodes msg, ahandle:%p", pVgroup->vgId, ahandle); for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { SRpcIpSet ipSet = mgmtGetIpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp); + mTrace("vgId:%d, send drop vnode msg to dnode:%d, ahandle:%p", pVgroup->vgId, pVgroup->vnodeGid[i].dnodeId, ahandle); mgmtSendDropVnodeMsg(pVgroup->vgId, &ipSet, ahandle); } } diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 091103a911d7195d28761bf4ff053b9ac1f33725..3b27344f2098baa322c927283798ed1dfab0a740 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -352,7 +352,6 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SDMStatusMsg *pStatus) { pLoad->status = pVnode->status; pLoad->role = pVnode->role; pLoad->replica = pVnode->syncCfg.replica; - pStatus->openVnodes++; } void vnodeBuildStatusMsg(void *param) { diff --git a/tests/script/general/db/delete.sim b/tests/script/general/db/delete.sim new file mode 100644 index 0000000000000000000000000000000000000000..f86774c2cf924d0e9c16a4031c944c64fc8e5343 --- /dev/null +++ b/tests/script/general/db/delete.sim @@ -0,0 +1,59 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ======== step1 +sql create database db blocks 2 maxtables 1000 +sql create table db.mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$tbPrefix = db.t +$i = 0 +while $i < 2000 + $tb = $tbPrefix . $i + sql create table $tb using db.mt tags( $i ) + $i = $i + 1 +endw + +print ======== step2 +sleep 1000 +sql drop database db +sql show databases +if $rows != 0 then + return -1 +endi + +sleep 1000 +sql show dnodes +print dnode1 openVnodes $data2_1 +if $data2_1 != 0 then + return -1 +endi + +print ======= step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +step3: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show mnodes +print dnode1 role $data2_1 +if $data2_1 != master then + goto step3 +endi + +sleep 1000 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index c9cb6960168be34d8e573729c7f219f000d2507b..94c9c71edc8115b08e4f169e5c523acf255f028c 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -49,6 +49,7 @@ cd ../../../debug; make ./test.sh -f general/db/basic3.sim ./test.sh -f general/db/basic4.sim ./test.sh -f general/db/basic5.sim +./test.sh -f unique/db/delete.sim ./test.sh -f general/db/delete_reuse1.sim ./test.sh -f general/db/delete_reuse2.sim ./test.sh -f general/db/delete_reusevnode.sim @@ -243,15 +244,15 @@ cd ../../../debug; make #slguan ./test.sh -u -f unique/big/maxvnodes.sim ./test.sh -u -f unique/big/tcp.sim -##./test.sh -u -f unique/cluster/balance1.sim -##./test.sh -u -f unique/cluster/balance2.sim -##./test.sh -u -f unique/cluster/balance3.sim +#jeff ./test.sh -u -f unique/cluster/balance1.sim +#jeff ./test.sh -u -f unique/cluster/balance2.sim +#jeff ./test.sh -u -f unique/cluster/balance3.sim #./test.sh -u -f unique/cluster/cache.sim ./test.sh -u -f unique/column/replica3.sim -#./test.sh -u -f unique/db/commit.sim -#./test.sh -u -f unique/db/delete.sim +#hongze ./test.sh -u -f unique/db/commit.sim +./test.sh -u -f unique/db/delete.sim #./test.sh -u -f unique/db/delete_part.sim ##./test.sh -u -f unique/db/replica_add12.sim ##./test.sh -u -f unique/db/replica_add13.sim @@ -269,7 +270,7 @@ cd ../../../debug; make ##./test.sh -u -f unique/dnode/offline2.sim ./test.sh -u -f unique/dnode/remove1.sim #hongze ./test.sh -u -f unique/dnode/remove2.sim -#./test.sh -u -f unique/dnode/vnode_clean.sim +./test.sh -u -f unique/dnode/vnode_clean.sim ./test.sh -u -f unique/http/admin.sim ./test.sh -u -f unique/http/opentsdb.sim @@ -302,6 +303,6 @@ cd ../../../debug; make #./test.sh -u -f unique/vnode/replica2_basic.sim ./test.sh -u -f unique/vnode/replica2_basic2.sim #./test.sh -u -f unique/vnode/replica2_repeat.sim -##./test.sh -u -f unique/vnode/replica3_basic.sim +#hongze ./test.sh -u -f unique/vnode/replica3_basic.sim #./test.sh -u -f unique/vnode/replica3_repeat.sim #./test.sh -u -f unique/vnode/replica3_vgroup.sim diff --git a/tests/script/unique/db/commit.sim b/tests/script/unique/db/commit.sim index 648cd8db2fe592b2405017d9d850c76ffeefb117..5bf6ea6f10bf7e52581785459aa03de321f91c1c 100644 --- a/tests/script/unique/db/commit.sim +++ b/tests/script/unique/db/commit.sim @@ -72,8 +72,8 @@ sql import into tb values (now - 10d , -10 ) sql import into tb values (now - 11d , -11 ) sql select * from tb order by ts desc -print ===> rows $rows -print ===> last $data01 +print ===> rows $rows expect $num +print ===> last $data01 expect $data01 if $rows != $num then return -1 diff --git a/tests/script/unique/db/delete.sim b/tests/script/unique/db/delete.sim index e222db8d70fff0dfb17d2731a346557b5ddb0b8e..dcdd1ae9e9ae98880579e3cca505c244ecfa4e35 100644 --- a/tests/script/unique/db/delete.sim +++ b/tests/script/unique/db/delete.sim @@ -1,7 +1,4 @@ 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 @@ -18,20 +15,20 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10 print ========= start dnodes system sh/exec_up.sh -n dnode1 -s start +sleep 3000 sql connect sql create dnode $hostname2 system sh/exec_up.sh -n dnode2 -s start sql create dnode $hostname3 system sh/exec_up.sh -n dnode3 -s start -sleep 3000 print ======== step1 -sql create database db replica 3 ablocks 2 tblocks 5 maxtables 10000 +sql create database db replica 3 blocks 2 maxtables 1000 sql create table db.mt (ts timestamp, tbcol int) TAGS(tgcol int) $tbPrefix = db.t $i = 0 -while $i < 100000 +while $i < 2000 $tb = $tbPrefix . $i sql create table $tb using db.mt tags( $i ) $i = $i + 1 @@ -45,6 +42,48 @@ if $rows != 0 then return -1 endi +sleep 3000 +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 0 then + return -1 +endi +if $data2_3 != 0 then + return -1 +endi + +print ======== step3 + +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 1000 +system sh/exec.sh -n dnode1 -s start -t +system sh/exec.sh -n dnode2 -s start -t +system sh/exec.sh -n dnode3 -s start -t + +$x = 0 +step3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print dnode1 role $data2_1 +if $data2_1 != master then + goto step3 +endi + +sleep 1000 + system sh/exec_up.sh -n dnode1 -s stop -x SIGINT system sh/exec_up.sh -n dnode2 -s stop -x SIGINT system sh/exec_up.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/vnode_clean.sim b/tests/script/unique/dnode/vnode_clean.sim index da34c7bc9b3b26f0a6bad497ae02ea253b97bb7a..d46e1a751ed788249f158e519ef901cdf46b886c 100644 --- a/tests/script/unique/dnode/vnode_clean.sim +++ b/tests/script/unique/dnode/vnode_clean.sim @@ -29,7 +29,7 @@ sql insert into d1.t1 values(now+5s, 11) sql show dnodes print dnode1 openVnodes $data2_1 -if $data2_1 != 3 then +if $data2_1 != 1 then return -1 endi @@ -41,16 +41,16 @@ $x = 0 show2: $x = $x + 1 sleep 2000 - if $x == 30 then + if $x == 10 then return -1 endi sql show dnodes print dnode1 openVnodes $data2_1 print dnode2 openVnodes $data2_2 -if $data2_1 != 4 then +if $data2_1 != 0 then goto show2 endi -if $data2_2 != 3 then +if $data2_2 != 1 then goto show2 endi @@ -68,7 +68,7 @@ $x = 0 sql show dnodes print dnode1 openVnodes $data2_1 print dnode2 openVnodes $data2_2 -if $data2_1 != 4 then +if $data2_1 != 0 then return -1 endi if $data2_2 != 2 then @@ -82,7 +82,7 @@ $x = 0 show4: $x = $x + 1 sleep 2000 - if $x == 30 then + if $x == 10 then return -1 endi sql show dnodes @@ -91,7 +91,7 @@ print dnode2 openVnodes $data2_2 if $data2_1 != 2 then goto show4 endi -if $data2_2 != NULL then +if $data2_2 != null then goto show4 endi if $rows != 1 then @@ -102,13 +102,8 @@ system sh/exec_up.sh -n dnode2 -s stop -x SIGINT print ========== step5 sleep 2000 -sql create dnode $hostname2 -system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 -system sh/cfg.sh -n dnode2 -c wallevel -v 1 -system sh/exec_up.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec_up.sh -n dnode3 -s start $x = 0 show5: @@ -119,11 +114,11 @@ show5: endi sql show dnodes print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 4 then +print dnode3 openVnodes $data2_3 +if $data2_1 != 0 then goto show5 endi -if $data2_2 != 2 then +if $data2_3 != 2 then goto show5 endi @@ -138,17 +133,17 @@ sql insert into d3.t3 values(now+5s, 31) sql show dnodes print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 -if $data2_1 != 4 then +print dnode2 openVnodes $data2_3 +if $data2_1 != 0 then return -1 endi -if $data2_2 != 1 then +if $data2_3 != 3 then return -1 endi print ========== step7 -sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +sql create dnode $hostname4 +system sh/exec_up.sh -n dnode4 -s start $x = 0 show7: @@ -160,15 +155,15 @@ show7: sql show dnodes print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data2_3 -if $data2_1 != 4 then +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then goto show7 endi -if $data2_2 != 2 then +if $data2_3 != 2 then goto show7 endi -if $data2_3 != 3 then +if $data2_4 != 1 then goto show7 endi @@ -185,49 +180,49 @@ $x = 0 show8: $x = $x + 1 sleep 2000 - if $x == 30 then + if $x == 10 then return -1 endi sql show dnodes print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data2_3 -if $data2_1 != 4 then +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then goto show8 endi -if $data2_2 != 2 then +if $data2_3 != 2 then goto show8 endi -if $data2_3 != 2 then +if $data2_4 != 2 then goto show8 endi print ========== step9 -sql drop dnode $hostname2 +sql drop dnode $hostname3 $x = 0 show9: $x = $x + 1 sleep 2000 - if $x == 30 then + if $x == 10 then return -1 endi sql show dnodes print dnode1 openVnodes $data2_1 -print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data2_3 -if $data2_1 != 4 then +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then goto show9 endi -if $data2_2 != NULL then +if $data2_3 != null then goto show9 endi -if $data2_3 != 0 then +if $data2_4 != 4 then goto show9 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT print ========== step10 sql select * from d1.t1 order by t desc