From cd6624214bdd4547701312908217dbe4b4cc0564 Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 3 May 2020 12:26:54 +0800 Subject: [PATCH] [TD-150] deadlock in balance --- src/inc/tbalance.h | 1 + src/mnode/src/mgmtBalance.c | 1 + src/mnode/src/mgmtDnode.c | 1 + tests/script/unique/dnode/balance1.sim | 105 ++++++++++++------------- 4 files changed, 53 insertions(+), 55 deletions(-) diff --git a/src/inc/tbalance.h b/src/inc/tbalance.h index 9ffa6332c6..fee0452545 100644 --- a/src/inc/tbalance.h +++ b/src/inc/tbalance.h @@ -26,6 +26,7 @@ struct SDnodeObj; int32_t balanceInit(); void balanceCleanUp(); void balanceNotify(); +void balanceUpdateMgmt(); void balanceReset(); int32_t balanceAllocVnodes(struct SVgObj *pVgroup); int32_t balanceDropDnode(struct SDnodeObj *pDnode); diff --git a/src/mnode/src/mgmtBalance.c b/src/mnode/src/mgmtBalance.c index 17d4a4114b..d16a06fc5c 100644 --- a/src/mnode/src/mgmtBalance.c +++ b/src/mnode/src/mgmtBalance.c @@ -29,6 +29,7 @@ int32_t balanceInit() { return TSDB_CODE_SUCCESS; } void balanceCleanUp() {} void balanceNotify() {} +void balanceUpdateMgmt() {} void balanceReset() {} int32_t balanceAllocVnodes(SVgObj *pVgroup) { diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 6629737787..90ee40dc93 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -322,6 +322,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) { if (pDnode->status == TAOS_DN_STATUS_OFFLINE) { mTrace("dnode:%d, from offline to online", pDnode->dnodeId); pDnode->status = TAOS_DN_STATUS_READY; + balanceUpdateMgmt(); balanceNotify(); } diff --git a/tests/script/unique/dnode/balance1.sim b/tests/script/unique/dnode/balance1.sim index ea51b05778..33de448c37 100644 --- a/tests/script/unique/dnode/balance1.sim +++ b/tests/script/unique/dnode/balance1.sim @@ -1,10 +1,5 @@ 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 @@ -49,8 +44,8 @@ sql insert into d1.t1 values(now+4s, 12) sql insert into d1.t1 values(now+5s, 11) sql show dnodes -print dnode1 openVnodes $data3_1 -if $data3_1 != 1 then +print dnode1 openVnodes $data2_1 +if $data2_1 != 1 then return -1 endi @@ -68,12 +63,12 @@ show2: endi sql show dnodes -print dnode1 openVnodes $data3_1 -print dnode2 openVnodes $data3_2 -if $data3_1 != 0 then +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then goto show2 endi -if $data3_2 != 1 then +if $data2_2 != 1 then goto show2 endi @@ -87,12 +82,12 @@ sql insert into d2.t2 values(now+4s, 22) sql insert into d2.t2 values(now+5s, 21) sql show dnodes -print dnode1 openVnodes $data3_1 -print dnode2 openVnodes $data3_2 -if $data3_1 != 0 then +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then return -1 endi -if $data3_2 != 2 then +if $data2_2 != 2 then return -1 endi @@ -108,12 +103,12 @@ show4: endi sql show dnodes -print dnode1 openVnodes $data3_1 -print dnode2 openVnodes $data3_2 -if $data3_1 != 2 then +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 2 then goto show4 endi -if $data3_2 != null then +if $data2_2 != null then goto show4 endi if $rows != 1 then @@ -135,16 +130,16 @@ show5: endi sql show dnodes -print dnode1 openVnodes $data3_1 -print dnode2 openVnodes $data3_2 -print dnode3 openVnodes $data3_3 -if $data3_1 != 0 then +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 0 then goto show5 endi -if $data3_2 != null then +if $data2_2 != null then goto show5 endi -if $data3_3 != 2 then +if $data2_3 != 2 then goto show5 endi @@ -158,17 +153,17 @@ sql insert into d3.t3 values(now+4s, 32) sql insert into d3.t3 values(now+5s, 31) sql show dnodes -print dnode1 openVnodes $data3_1 -print dnode2 openVnodes $data3_2 -print dnode3 openVnodes $data3_3 +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 -if $data3_1 != 0 then +if $data2_1 != 0 then return -1 endi -if $data3_2 != null then +if $data2_2 != null then return -1 endi -if $data3_3 != 3 then +if $data2_3 != 3 then return -1 endi @@ -185,20 +180,20 @@ show7: endi sql show dnodes -print dnode1 openVnodes $data3_1 -print dnode2 openVnodes $data3_2 -print dnode3 openVnodes $data3_3 -print dnode4 openVnodes $data3_4 -if $data3_1 != 0 then +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then goto show7 endi -if $data3_2 != null then +if $data2_2 != null then goto show7 endi -if $data3_3 != 2 then +if $data2_3 != 2 then goto show7 endi -if $data3_4 != 1 then +if $data2_4 != 1 then goto show7 endi @@ -212,21 +207,21 @@ sql insert into d4.t4 values(now+4s, 42) sql insert into d4.t4 values(now+5s, 41) sql show dnodes -print dnode1 openVnodes $data3_1 -print dnode2 openVnodes $data3_2 -print dnode3 openVnodes $data3_3 -print dnode4 openVnodes $data3_4 +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 -if $data3_1 != 0 then +if $data2_1 != 0 then return -1 endi -if $data3_2 != null then +if $data2_2 != null then return -1 endi -if $data3_3 != 2 then +if $data2_3 != 2 then return -1 endi -if $data3_4 != 2 then +if $data2_4 != 2 then return -1 endi @@ -242,21 +237,21 @@ show9: endi sql show dnodes -print dnode1 openVnodes $data3_1 -print dnode2 openVnodes $data3_2 -print dnode3 openVnodes $data3_3 -print dnode4 openVnodes $data3_4 +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 -if $data3_1 != 0 then +if $data2_1 != 0 then goto show9 endi -if $data3_2 != null then +if $data2_2 != null then goto show9 endi -if $data3_3 != null then +if $data2_3 != null then goto show9 endi -if $data3_4 != 4 then +if $data2_4 != 4 then goto show9 endi -- GitLab