diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 72b9fa0082..bc2c52e570 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -73,8 +73,8 @@ static const SSysDbTableSchema arbGroupsSchema[] = { {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "v1_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, {.name = "v2_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, - {.name = "is_sync", .bytes = 100, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, - //{.name = "sync_code", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, + {.name = "is_sync", .bytes = 6, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, + {.name = "check_sync_code", .bytes = 100, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "assigned_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, {.name = "assigned_token", .bytes = TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "assigned_acked", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, diff --git a/source/dnode/mnode/impl/src/mndArbGroup.c b/source/dnode/mnode/impl/src/mndArbGroup.c index 7ea0be38e6..bf35c3bc5e 100644 --- a/source/dnode/mnode/impl/src/mndArbGroup.c +++ b/source/dnode/mnode/impl/src/mndArbGroup.c @@ -1355,13 +1355,11 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock mInfo("vgId:%d, arb group sync:%d, code:%d, update time:%" PRId64, pGroup->vgId, pGroup->isSync, pGroup->code, pGroup->updateTimeMs); - char strSync[100] = {0}; - char bufUpdateTime[40] = {0}; - (void)formatTimestamp(bufUpdateTime, pGroup->updateTimeMs, TSDB_TIME_PRECISION_MILLI); + char strSync[6] = {0}; if (pGroup->isSync == 1) { - tsnprintf(strSync, 100, "true(code:%d,%s)", pGroup->code, bufUpdateTime); + tsnprintf(strSync, 6, "true"); } else { - tsnprintf(strSync, 100, "false(code:%d,%s)", 100, pGroup->code, bufUpdateTime); + tsnprintf(strSync, 6, "false"); } char sync[100 + VARSTR_HEADER_SIZE] = {0}; @@ -1369,6 +1367,16 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)sync, false), pGroup, &lino, _OVER); + char strCheckSyncCode[100] = {0}; + char bufUpdateTime[40] = {0}; + (void)formatTimestamp(bufUpdateTime, pGroup->updateTimeMs, TSDB_TIME_PRECISION_MILLI); + tsnprintf(strCheckSyncCode, 100, "%d(%s)", pGroup->code, bufUpdateTime); + + char checkSyncCode[100 + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(checkSyncCode, strCheckSyncCode, 100 + VARSTR_HEADER_SIZE); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)checkSyncCode, false), pGroup, &lino, _OVER); + if (pGroup->assignedLeader.dnodeId != 0) { pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false), diff --git a/tests/army/cluster/arbgroup_sync.py b/tests/army/cluster/arbgroup_sync.py index 9fd8e7b1f3..9152263a59 100644 --- a/tests/army/cluster/arbgroup_sync.py +++ b/tests/army/cluster/arbgroup_sync.py @@ -40,14 +40,17 @@ class TDTestCase(TBase): while count < 100: tdSql.query("show arbgroups;") - if tdSql.getData(0, 4) == 1: + if tdSql.getData(0, 4) == 'true': break - tdLog.info("wait 1 seconds for is sync") + tdLog.info("wait %d seconds for is sync"%count) time.sleep(1) count += 1 - + + if count == 100: + tdLog.exit("arbgroup sync failed") + return tdSql.query("show db.vgroups;") @@ -67,10 +70,14 @@ class TDTestCase(TBase): if(tdSql.getData(0, 4) == "assigned ") or (tdSql.getData(0, 6) == "assigned "): break - tdLog.info("wait 1 seconds for set assigned") + tdLog.info("wait %d seconds for set assigned"%count) time.sleep(1) count += 1 + + if count == 100: + tdLog.exit("check assigned failed") + return def stop(self): tdSql.close() diff --git a/tests/army/cluster/arbitrator.py b/tests/army/cluster/arbitrator.py index 385358e5cc..947397b395 100644 --- a/tests/army/cluster/arbitrator.py +++ b/tests/army/cluster/arbitrator.py @@ -46,13 +46,17 @@ class TDTestCase(TBase): while count < 100: tdSql.query("show arbgroups;") - if tdSql.getData(0, 4) == 1: + if tdSql.getData(0, 4) == 'true': break - tdLog.info("wait 1 seconds for is sync") + tdLog.info("wait %d seconds for is sync"%count) time.sleep(1) count += 1 + + if count == 100: + tdLog.exit("arbgroup sync failed") + return tdSql.query("show db.vgroups;") @@ -73,10 +77,14 @@ class TDTestCase(TBase): if(tdSql.getData(0, 4) == "assigned ") or (tdSql.getData(0, 6) == "assigned "): break - tdLog.info("wait 1 seconds for set assigned") + tdLog.info("wait %d seconds for set assigned"%count) time.sleep(1) count += 1 + + if count == 100: + tdLog.exit("check assigned failed") + return tdSql.execute("INSERT INTO d0 VALUES (NOW, 10.3, 219, 0.31);")