提交 f4bb5d06 编写于 作者: S Shengliang Guan

minor changes

上级 a326b290
...@@ -463,7 +463,7 @@ static int32_t mndProcessCreateDbReq(SMnodeMsg *pReq) { ...@@ -463,7 +463,7 @@ static int32_t mndProcessCreateDbReq(SMnodeMsg *pReq) {
pCreate->commitTime = htonl(pCreate->commitTime); pCreate->commitTime = htonl(pCreate->commitTime);
pCreate->fsyncPeriod = htonl(pCreate->fsyncPeriod); pCreate->fsyncPeriod = htonl(pCreate->fsyncPeriod);
mDebug("db:%s, start to create", pCreate->db); mDebug("db:%s, start to create, vgroups:%d", pCreate->db, pCreate->numOfVgroups);
SDbObj *pDb = mndAcquireDb(pMnode, pCreate->db); SDbObj *pDb = mndAcquireDb(pMnode, pCreate->db);
if (pDb != NULL) { if (pDb != NULL) {
...@@ -476,6 +476,9 @@ static int32_t mndProcessCreateDbReq(SMnodeMsg *pReq) { ...@@ -476,6 +476,9 @@ static int32_t mndProcessCreateDbReq(SMnodeMsg *pReq) {
mError("db:%s, failed to create since %s", pCreate->db, terrstr()); mError("db:%s, failed to create since %s", pCreate->db, terrstr());
return -1; return -1;
} }
} else if (terrno != TSDB_CODE_MND_DB_NOT_EXIST) {
mError("db:%s, failed to create since %s", pCreate->db, terrstr());
return -1;
} }
SUserObj *pOperUser = mndAcquireUser(pMnode, pReq->user); SUserObj *pOperUser = mndAcquireUser(pMnode, pReq->user);
......
...@@ -809,7 +809,7 @@ static bool mndTransPerformUndoLogStage(SMnode *pMnode, STrans *pTrans) { ...@@ -809,7 +809,7 @@ static bool mndTransPerformUndoLogStage(SMnode *pMnode, STrans *pTrans) {
mDebug("trans:%d, stage from undoLog to rollback", pTrans->id); mDebug("trans:%d, stage from undoLog to rollback", pTrans->id);
continueExec = true; continueExec = true;
} else { } else {
mDebug("trans:%d, stage keep on undoLog since %s", pTrans->id, terrstr()); mError("trans:%d, stage keep on undoLog since %s", pTrans->id, terrstr());
continueExec = false; continueExec = false;
} }
...@@ -825,7 +825,7 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) { ...@@ -825,7 +825,7 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) {
mDebug("trans:%d, stage from undoAction to undoLog", pTrans->id); mDebug("trans:%d, stage from undoAction to undoLog", pTrans->id);
continueExec = true; continueExec = true;
} else if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) { } else if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) {
mDebug("trans:%d, stage keep on undoAction since %s", pTrans->id, tstrerror(code)); mError("trans:%d, stage keep on undoAction since %s", pTrans->id, tstrerror(code));
continueExec = false; continueExec = false;
} else { } else {
pTrans->failedTimes++; pTrans->failedTimes++;
......
...@@ -273,15 +273,10 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2 ...@@ -273,15 +273,10 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2
SDnodeObj *pDnode = pObj; SDnodeObj *pDnode = pObj;
SArray *pArray = p1; SArray *pArray = p1;
pDnode->numOfVnodes = mndGetVnodesNum(pMnode, pDnode->id);
int64_t curMs = taosGetTimestampMs(); int64_t curMs = taosGetTimestampMs();
bool online = mndIsDnodeOnline(pMnode, pDnode, curMs); bool online = mndIsDnodeOnline(pMnode, pDnode, curMs);
if (online && pDnode->numOfSupportVnodes > 0) { bool isMnode = mndIsMnode(pMnode, pDnode->id);
taosArrayPush(pArray, pDnode); pDnode->numOfVnodes = mndGetVnodesNum(pMnode, pDnode->id);
}
bool isMnode = mndIsMnode(pMnode, pDnode->id);
mDebug("dnode:%d, vnodes:%d supportVnodes:%d isMnode:%d online:%d", pDnode->id, pDnode->numOfVnodes, mDebug("dnode:%d, vnodes:%d supportVnodes:%d isMnode:%d online:%d", pDnode->id, pDnode->numOfVnodes,
pDnode->numOfSupportVnodes, isMnode, online); pDnode->numOfSupportVnodes, isMnode, online);
...@@ -290,6 +285,9 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2 ...@@ -290,6 +285,9 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2
pDnode->numOfVnodes++; pDnode->numOfVnodes++;
} }
if (online && pDnode->numOfSupportVnodes > 0) {
taosArrayPush(pArray, pDnode);
}
return true; return true;
} }
...@@ -311,7 +309,7 @@ static SArray *mndBuildDnodesArray(SMnode *pMnode) { ...@@ -311,7 +309,7 @@ static SArray *mndBuildDnodesArray(SMnode *pMnode) {
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) { static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes; float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes;
float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes; float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes;
return d1Score > d2Score ? 1 : 0; return d1Score >= d2Score ? 1 : 0;
} }
static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) { static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) {
......
...@@ -13,28 +13,17 @@ ...@@ -13,28 +13,17 @@
class MndTestDb : public ::testing::Test { class MndTestDb : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { static void SetUpTestSuite() { test.Init("/tmp/mnode_test_db", 9030); }
test.Init("/tmp/mnode_test_db", 9030); static void TearDownTestSuite() { test.Cleanup(); }
const char* fqdn = "localhost";
const char* firstEp = "localhost:9030";
server2.Start("/tmp/mnode_test_db2", fqdn, 9031, firstEp); static Testbase test;
}
static void TearDownTestSuite() {
server2.Stop();
test.Cleanup();
}
static Testbase test;
static TestServer server2;
public: public:
void SetUp() override {} void SetUp() override {}
void TearDown() override {} void TearDown() override {}
}; };
Testbase MndTestDb::test; Testbase MndTestDb::test;
TestServer MndTestDb::server2;
TEST_F(MndTestDb, 01_ShowDb) { TEST_F(MndTestDb, 01_ShowDb) {
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
......
...@@ -2,15 +2,16 @@ ...@@ -2,15 +2,16 @@
#======================b1-start=============== #======================b1-start===============
# ---- user # ---- user
./test.sh -f general/user/basic1.sim ./test.sh -f sim/user/basic1.sim
# ---- db # ---- db
./test.sh -f general/db/basic1.sim ./test.sh -f sim/db/basic1.sim
./test.sh -f sim/db/error1.sim
# ---- table # ---- table
./test.sh -f general/table/basic1.sim ./test.sh -f sim/table/basic1.sim
# ---- dnode # ---- dnode
./test.sh -f unique/dnode/basic1.sim ./test.sh -f sim/dnode/basic1.sim
#======================b1-end=============== #======================b1-end===============
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
system sh/deploy.sh -n dnode2 -i 2
system sh/exec.sh -n dnode2 -s start
sql connect
print ========== create dnodes
sql create dnode $hostname port 7200
$x = 0
create1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
if $data4_2 != ready then
goto create1
endi
print ========== stop dnode2
system sh/exec.sh -n dnode2 -s stop -x SIGKILL
print =============== create database
sql_error create database d1 vgroups 4
print ========== start dnode2
system sh/exec.sh -n dnode2 -s start
print =============== re-create database
$x = 0
re-create1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql create database d1 vgroups 2 -x re-create1
sql show databases
if $rows != 1 then
return -1
endi
if $data00 != d1 then
return -1
endi
if $data02 != 2 then
return -1
endi
if $data03 != 0 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册