From 18c8b217167f8aa39ec807074c0e049efc1d0b36 Mon Sep 17 00:00:00 2001 From: slguan Date: Mon, 27 Apr 2020 19:15:04 +0800 Subject: [PATCH] [TD-184] --- src/client/src/tscServer.c | 12 ++--- src/plugins/http/src/httpSystem.c | 2 +- src/vnode/src/vnodeMain.c | 4 +- tests/script/unique/db/replica_add12.sim | 60 +++++++++++++++--------- 4 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 0d33bec38d..41c94bc4bd 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -294,11 +294,6 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { } } } - - if (pRes->code == TSDB_CODE_SUCCESS) { - tscTrace("%p reset retry counter to be 0 due to success rsp, old:%d", pSql, pSql->retry); - pSql->retry = 0; - } pRes->rspLen = 0; @@ -308,6 +303,11 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { tscTrace("%p query is cancelled, code:%d", pSql, tstrerror(pRes->code)); } + if (pRes->code == TSDB_CODE_SUCCESS) { + tscTrace("%p reset retry counter to be 0 due to success rsp, old:%d", pSql, pSql->retry); + pSql->retry = 0; + } + if (pRes->code != TSDB_CODE_QUERY_CANCELLED) { assert(rpcMsg->msgType == pCmd->msgType + 1); pRes->code = rpcMsg->code; @@ -569,7 +569,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pSql->cmd.msgType = TSDB_MSG_TYPE_SUBMIT; tscSetDnodeIpList(pSql, pTableMeta); - tscTrace("%p build submit msg, vgId:%d numOfVgroup:%d", pSql, vgId, htonl(pMsgDesc->numOfVnodes)); + tscTrace("%p build submit msg, vgId:%d numOfVgroup:%d numberOfIP:%d", pSql, vgId, htonl(pMsgDesc->numOfVnodes), pSql->ipList.numOfIps); return TSDB_CODE_SUCCESS; } diff --git a/src/plugins/http/src/httpSystem.c b/src/plugins/http/src/httpSystem.c index 355fdf2fd0..07aa880a30 100644 --- a/src/plugins/http/src/httpSystem.c +++ b/src/plugins/http/src/httpSystem.c @@ -117,7 +117,7 @@ void httpCleanUpSystem() { httpPrint("http service cleanup"); httpStopSystem(); -#if 1 +#if 0 if (httpServer == NULL) { return; } diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 9ae0588771..57f0afbe8f 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -667,7 +667,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { fclose(fp); free(content); - dPrint("pVnode:%p vgId:%d, save vnode version successed", pVnode, pVnode->vgId); + dPrint("pVnode:%p vgId:%d, save vnode version:%" PRId64 " successed", pVnode, pVnode->vgId, pVnode->version); return 0; } @@ -675,7 +675,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { static bool vnodeReadVersion(SVnodeObj *pVnode) { char versionFile[TSDB_FILENAME_LEN + 30] = {0}; sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); - FILE *fp = fopen(versionFile, "w"); + FILE *fp = fopen(versionFile, "r"); if (!fp) { dError("pVnode:%p vgId:%d, failed to open vnode version file for write, error:%s", pVnode, pVnode->vgId, strerror(errno)); return false; diff --git a/tests/script/unique/db/replica_add12.sim b/tests/script/unique/db/replica_add12.sim index 969a2a2091..29f9fdbea8 100644 --- a/tests/script/unique/db/replica_add12.sim +++ b/tests/script/unique/db/replica_add12.sim @@ -145,7 +145,9 @@ if $rows != 2 then return -1 endi +sql reset query cache sleep 2000 + print ========= step5 system sh/exec_up.sh -n dnode2 -s stop -x SIGINT sleep 5000 @@ -155,7 +157,7 @@ if $rows != 2 then return -1 endi -sql select * from d2.t2 +sql select * from d2.t2 if $rows != 2 then return -1 endi @@ -172,11 +174,12 @@ endi print ===== insert data - sql insert into d1.t1 values(now, 3) -sql insert into d2.t2 values(now, 3) +# no master +sql_error insert into d2.t2 values(now, 3) sql insert into d3.t3 values(now, 3) -sql insert into d4.t4 values(now, 3) +# no master +sql_error insert into d4.t4 values(now, 3) sql select * from d1.t1 if $rows != 3 then @@ -184,7 +187,7 @@ if $rows != 3 then endi sql select * from d2.t2 -if $rows != 3 then +if $rows != 2 then return -1 endi @@ -194,32 +197,49 @@ if $rows != 3 then endi sql select * from d4.t4 -if $rows != 3 then +if $rows != 2 then return -1 endi print ========= step6 system sh/exec_up.sh -n dnode2 -s start -sleep 10000 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -sleep 10000 - -sql insert into d1.t1 values(now, 4) -sql insert into d2.t2 values(now, 4) -sql insert into d3.t3 values(now, 4) -sql insert into d4.t4 values(now, 4) +sleep 5000 +sql insert into d2.t2 values(now, 3) +sql insert into d4.t4 values(now, 3) sql select * from d1.t1 -if $rows != 4 then +if $rows != 3 then return -1 endi sql select * from d2.t2 -if $rows != 4 then +if $rows != 3 then return -1 endi sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step61 + +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +sleep 5000 + +# no master +sql_error insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +# no master +sql_error insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d2.t2 if $rows != 4 then return -1 endi @@ -231,9 +251,7 @@ endi print ========= step7 system sh/exec_up.sh -n dnode3 -s start -sleep 10000 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -sleep 10000 +sleep 5000 sql insert into d1.t1 values(now, 5) sql insert into d2.t2 values(now, 5) @@ -241,7 +259,7 @@ sql insert into d3.t3 values(now, 5) sql insert into d4.t4 values(now, 5) sql select * from d1.t1 -if $rows != 5 then +if $rows != 4 then return -1 endi @@ -251,7 +269,7 @@ if $rows != 5 then endi sql select * from d3.t3 -if $rows != 5 then +if $rows != 4 then return -1 endi -- GitLab