Merge pull request #5909 from taosdata/enhance/TD-3572
[TD-3572]<enhance>: response out of dnodes if #dnodes <= maxDbR…
This commit is contained in:
commit
5a412df02a
|
@ -31,6 +31,7 @@ enum _TSDB_DB_STATUS {
|
|||
int32_t mnodeInitDbs();
|
||||
void mnodeCleanupDbs();
|
||||
int64_t mnodeGetDbNum();
|
||||
int32_t mnodeGetDbMaxReplica();
|
||||
SDbObj *mnodeGetDb(char *db);
|
||||
SDbObj *mnodeGetDbByTableName(char *db);
|
||||
void * mnodeGetNextDb(void *pIter, SDbObj **pDb);
|
||||
|
|
|
@ -74,6 +74,24 @@ int64_t mnodeGetDbNum() {
|
|||
return sdbGetNumOfRows(tsDbSdb);
|
||||
}
|
||||
|
||||
int32_t mnodeGetDbMaxReplica() {
|
||||
int32_t maxReplica = 0;
|
||||
SDbObj *pDb = NULL;
|
||||
void *pIter = NULL;
|
||||
|
||||
while (1) {
|
||||
pIter = mnodeGetNextDb(pIter, &pDb);
|
||||
if (pDb == NULL) break;
|
||||
|
||||
if (pDb->cfg.replications > maxReplica)
|
||||
maxReplica = pDb->cfg.replications;
|
||||
|
||||
mnodeDecDbRef(pDb);
|
||||
}
|
||||
|
||||
return maxReplica;
|
||||
}
|
||||
|
||||
static int32_t mnodeDbActionInsert(SSdbRow *pRow) {
|
||||
SDbObj *pDb = pRow->pObj;
|
||||
SAcctObj *pAcct = mnodeGetAcct(pDb->acct);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "mnodeDef.h"
|
||||
#include "mnodeInt.h"
|
||||
#include "mnodeDnode.h"
|
||||
#include "mnodeDb.h"
|
||||
#include "mnodeMnode.h"
|
||||
#include "mnodeSdb.h"
|
||||
#include "mnodeShow.h"
|
||||
|
@ -745,6 +746,14 @@ static int32_t mnodeDropDnodeByEp(char *ep, SMnodeMsg *pMsg) {
|
|||
return TSDB_CODE_MND_NO_REMOVE_MASTER;
|
||||
}
|
||||
|
||||
int32_t maxReplica = mnodeGetDbMaxReplica();
|
||||
int32_t dnodesNum = mnodeGetDnodesNum();
|
||||
if (dnodesNum <= maxReplica) {
|
||||
mError("dnode:%d, can't drop dnode:%s, #dnodes: %d, replia: %d", pDnode->dnodeId, ep, dnodesNum, maxReplica);
|
||||
mnodeDecDnodeRef(pDnode);
|
||||
return TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||
}
|
||||
|
||||
mInfo("dnode:%d, start to drop it", pDnode->dnodeId);
|
||||
|
||||
int32_t code = bnDropDnode(pDnode);
|
||||
|
|
|
@ -338,10 +338,6 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|||
print stop dnode1 and sleep 3000
|
||||
sleep 3000
|
||||
|
||||
sql drop dnode $hostname1
|
||||
print drop dnode1 and sleep 9000
|
||||
sleep 9000
|
||||
|
||||
sql show mnodes
|
||||
$dnode1Role = $data2_1
|
||||
$dnode4Role = $data2_4
|
||||
|
@ -357,6 +353,25 @@ endi
|
|||
print ============================== step6.1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$x = 0
|
||||
step6.1:
|
||||
$x = $x + 1
|
||||
sleep 1000
|
||||
if $x == 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show dnodes
|
||||
print dnode1 $data4_1
|
||||
|
||||
if $data4_1 != ready then
|
||||
goto step6.1
|
||||
endi
|
||||
|
||||
sql drop dnode $hostname1
|
||||
print drop dnode1 and sleep 9000
|
||||
sleep 9000
|
||||
|
||||
$x = 0
|
||||
show6:
|
||||
$x = $x + 1
|
||||
|
|
|
@ -97,7 +97,6 @@ if $data2_2 != 3 then
|
|||
endi
|
||||
|
||||
print ========== step3
|
||||
sql drop dnode $hostname2
|
||||
|
||||
$x = 0
|
||||
show3:
|
||||
|
@ -114,6 +113,7 @@ print dnode2 openVnodes $data2_2
|
|||
print ========== step4
|
||||
sql create dnode $hostname3
|
||||
system sh/exec.sh -n dnode3 -s start
|
||||
sql drop dnode $hostname2
|
||||
|
||||
$x = 0
|
||||
show4:
|
||||
|
@ -224,4 +224,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT
|
|||
system sh/exec.sh -n dnode5 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode6 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode7 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode8 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode8 -s stop -x SIGINT
|
||||
|
|
|
@ -98,7 +98,6 @@ endi
|
|||
|
||||
print ========== step3
|
||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||
sql drop dnode $hostname2
|
||||
|
||||
sql show dnodes
|
||||
print dnode1 openVnodes $data2_1
|
||||
|
@ -128,6 +127,26 @@ endi
|
|||
print ============ step 4.1
|
||||
system sh/exec.sh -n dnode2 -s start
|
||||
|
||||
$x = 0
|
||||
step4.1:
|
||||
$x = $x + 1
|
||||
sleep 1000
|
||||
if $x == 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show dnodes
|
||||
print dnode1 $data4_1
|
||||
print dnode2 $data4_2
|
||||
print dnode3 $data4_3
|
||||
print dnode4 $data4_4
|
||||
|
||||
if $data4_2 != ready then
|
||||
goto step4.1
|
||||
endi
|
||||
|
||||
sql drop dnode $hostname2
|
||||
|
||||
$x = 0
|
||||
show4:
|
||||
$x = $x + 1
|
||||
|
|
Loading…
Reference in New Issue