[TD-3572]<enhance>: response out of dnodes if #dnodes <= maxDbReplica
This commit is contained in:
parent
183e6ff05e
commit
f52cf50c5c
|
@ -31,6 +31,7 @@ enum _TSDB_DB_STATUS {
|
||||||
int32_t mnodeInitDbs();
|
int32_t mnodeInitDbs();
|
||||||
void mnodeCleanupDbs();
|
void mnodeCleanupDbs();
|
||||||
int64_t mnodeGetDbNum();
|
int64_t mnodeGetDbNum();
|
||||||
|
int32_t mnodeGetDbMaxReplica();
|
||||||
SDbObj *mnodeGetDb(char *db);
|
SDbObj *mnodeGetDb(char *db);
|
||||||
SDbObj *mnodeGetDbByTableName(char *db);
|
SDbObj *mnodeGetDbByTableName(char *db);
|
||||||
void * mnodeGetNextDb(void *pIter, SDbObj **pDb);
|
void * mnodeGetNextDb(void *pIter, SDbObj **pDb);
|
||||||
|
|
|
@ -74,6 +74,24 @@ int64_t mnodeGetDbNum() {
|
||||||
return sdbGetNumOfRows(tsDbSdb);
|
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) {
|
static int32_t mnodeDbActionInsert(SSdbRow *pRow) {
|
||||||
SDbObj *pDb = pRow->pObj;
|
SDbObj *pDb = pRow->pObj;
|
||||||
SAcctObj *pAcct = mnodeGetAcct(pDb->acct);
|
SAcctObj *pAcct = mnodeGetAcct(pDb->acct);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "mnodeDef.h"
|
#include "mnodeDef.h"
|
||||||
#include "mnodeInt.h"
|
#include "mnodeInt.h"
|
||||||
#include "mnodeDnode.h"
|
#include "mnodeDnode.h"
|
||||||
|
#include "mnodeDb.h"
|
||||||
#include "mnodeMnode.h"
|
#include "mnodeMnode.h"
|
||||||
#include "mnodeSdb.h"
|
#include "mnodeSdb.h"
|
||||||
#include "mnodeShow.h"
|
#include "mnodeShow.h"
|
||||||
|
@ -745,6 +746,14 @@ static int32_t mnodeDropDnodeByEp(char *ep, SMnodeMsg *pMsg) {
|
||||||
return TSDB_CODE_MND_NO_REMOVE_MASTER;
|
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);
|
mInfo("dnode:%d, start to drop it", pDnode->dnodeId);
|
||||||
|
|
||||||
int32_t code = bnDropDnode(pDnode);
|
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
|
print stop dnode1 and sleep 3000
|
||||||
sleep 3000
|
sleep 3000
|
||||||
|
|
||||||
sql drop dnode $hostname1
|
|
||||||
print drop dnode1 and sleep 9000
|
|
||||||
sleep 9000
|
|
||||||
|
|
||||||
sql show mnodes
|
sql show mnodes
|
||||||
$dnode1Role = $data2_1
|
$dnode1Role = $data2_1
|
||||||
$dnode4Role = $data2_4
|
$dnode4Role = $data2_4
|
||||||
|
@ -357,6 +353,25 @@ endi
|
||||||
print ============================== step6.1
|
print ============================== step6.1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
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
|
$x = 0
|
||||||
show6:
|
show6:
|
||||||
$x = $x + 1
|
$x = $x + 1
|
||||||
|
|
|
@ -97,7 +97,6 @@ if $data2_2 != 3 then
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print ========== step3
|
print ========== step3
|
||||||
sql drop dnode $hostname2
|
|
||||||
|
|
||||||
$x = 0
|
$x = 0
|
||||||
show3:
|
show3:
|
||||||
|
@ -114,6 +113,7 @@ print dnode2 openVnodes $data2_2
|
||||||
print ========== step4
|
print ========== step4
|
||||||
sql create dnode $hostname3
|
sql create dnode $hostname3
|
||||||
system sh/exec.sh -n dnode3 -s start
|
system sh/exec.sh -n dnode3 -s start
|
||||||
|
sql drop dnode $hostname2
|
||||||
|
|
||||||
$x = 0
|
$x = 0
|
||||||
show4:
|
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 dnode5 -s stop -x SIGINT
|
||||||
system sh/exec.sh -n dnode6 -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 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
|
print ========== step3
|
||||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
sql drop dnode $hostname2
|
|
||||||
|
|
||||||
sql show dnodes
|
sql show dnodes
|
||||||
print dnode1 openVnodes $data2_1
|
print dnode1 openVnodes $data2_1
|
||||||
|
@ -128,6 +127,26 @@ endi
|
||||||
print ============ step 4.1
|
print ============ step 4.1
|
||||||
system sh/exec.sh -n dnode2 -s start
|
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
|
$x = 0
|
||||||
show4:
|
show4:
|
||||||
$x = $x + 1
|
$x = $x + 1
|
||||||
|
|
Loading…
Reference in New Issue