From a3744f28b35f30ceb977f964d5d28d27d00683c5 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 8 Jun 2020 07:56:42 +0000 Subject: [PATCH 1/7] [TD-553] add usage stastics --- src/vnode/inc/vnodeInt.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index 7c95e81cf5..af7f764717 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -39,6 +39,9 @@ typedef struct { int8_t role; int64_t version; // current version int64_t fversion; // version on saved data file + int64_t totalStorage; //total bytes occupie + int64_t compStorage; + int64_t pointsWritten; //total data points written void *wqueue; void *rqueue; void *wal; From fe8b9e03c317ca9ba82345c17ec1b6b2f60df539 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 9 Jun 2020 03:13:58 +0000 Subject: [PATCH 2/7] [TD-553] add usage statistics function --- src/common/inc/tdataformat.h | 7 +++++-- src/common/src/tdataformat.c | 10 +++++++++- src/inc/tsdb.h | 16 ++++++++++++++++ src/tsdb/inc/tsdbMain.h | 2 ++ src/tsdb/src/tsdbMain.c | 16 +++++++++++++++- src/vnode/inc/vnodeInt.h | 3 --- src/vnode/src/vnodeMain.c | 10 ++++++---- 7 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index ec4e544e18..441af9a215 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -69,7 +69,8 @@ typedef struct { int version; // version int numOfCols; // Number of columns appended int tlen; // maximum length of a SDataRow without the header part - int flen; // First part length in a SDataRow after the header part + int16_t flen; // First part length in a SDataRow after the header part + int16_t vlen; // pure value part length, excluded the overhead STColumn columns[]; } STSchema; @@ -77,6 +78,7 @@ typedef struct { #define schemaVersion(s) ((s)->version) #define schemaTLen(s) ((s)->tlen) #define schemaFLen(s) ((s)->flen) +#define schemaVLen(s) ((s)->vlen) #define schemaColAt(s, i) ((s)->columns + i) #define tdFreeSchema(s) tfree((s)) @@ -105,7 +107,8 @@ typedef struct { int tCols; int nCols; int tlen; - int flen; + int16_t flen; + int16_t vlen; int version; STColumn *columns; } STSchemaBuilder; diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 7880a4b302..cb84c376eb 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -37,6 +37,7 @@ void *tdEncodeSchema(void *dst, STSchema *pSchema) { T_APPEND_MEMBER(dst, pSchema, STSchema, version); T_APPEND_MEMBER(dst, pSchema, STSchema, numOfCols); + T_APPEND_MEMBER(dst, pSchema, STSchema, vlen); for (int i = 0; i < schemaNCols(pSchema); i++) { STColumn *pCol = schemaColAt(pSchema, i); T_APPEND_MEMBER(dst, pCol, STColumn, type); @@ -53,10 +54,12 @@ void *tdEncodeSchema(void *dst, STSchema *pSchema) { STSchema *tdDecodeSchema(void **psrc) { int totalCols = 0; int version = 0; + int16_t vlen = 0; STSchemaBuilder schemaBuilder = {0}; T_READ_MEMBER(*psrc, int, version); T_READ_MEMBER(*psrc, int, totalCols); + T_READ_MEMBER(*psrc, int16_t, vlen); if (tdInitTSchemaBuilder(&schemaBuilder, version) < 0) return NULL; @@ -75,6 +78,7 @@ STSchema *tdDecodeSchema(void **psrc) { } STSchema *pSchema = tdGetSchemaFromBuilder(&schemaBuilder); + pSchema->vlen = vlen; tdDestroyTSchemaBuilder(&schemaBuilder); return pSchema; } @@ -100,6 +104,7 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) { pBuilder->nCols = 0; pBuilder->tlen = 0; pBuilder->flen = 0; + pBuilder->vlen = 0; pBuilder->version = version; } @@ -124,10 +129,12 @@ int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int3 if (IS_VAR_DATA_TYPE(type)) { colSetBytes(pCol, bytes); - pBuilder->tlen += (TYPE_BYTES[type] + sizeof(VarDataLenT) + bytes); + pBuilder->tlen += (TYPE_BYTES[type] + bytes); + pBuilder->vlen += bytes - sizeof(VarDataLenT); } else { colSetBytes(pCol, TYPE_BYTES[type]); pBuilder->tlen += TYPE_BYTES[type]; + pBuilder->vlen += TYPE_BYTES[type]; } pBuilder->nCols++; @@ -150,6 +157,7 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder) { schemaNCols(pSchema) = pBuilder->nCols; schemaTLen(pSchema) = pBuilder->tlen; schemaFLen(pSchema) = pBuilder->flen; + schemaVLen(pSchema) = pBuilder->vlen; memcpy(schemaColAt(pSchema, 0), pBuilder->columns, sizeof(STColumn) * pBuilder->nCols); diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index a678f213bb..bdb61e6ee1 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -65,6 +65,13 @@ typedef struct { int8_t compression; } STsdbCfg; +// --------- TSDB REPOSITORY USAGE STATISTICS +typedef struct { + int64_t totalStorage; //total bytes occupie + int64_t compStorage; + int64_t pointsWritten; //total data points written +}STsdbStat; + typedef void TsdbRepoT; // use void to hide implementation details from outside void tsdbSetDefaultCfg(STsdbCfg *pCfg); @@ -306,6 +313,15 @@ int32_t tsdbGetOneTableGroup(TsdbRepoT *tsdb, uint64_t uid, STableGroupInfo *pGr */ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle); +/** + * get the statistics of repo usage + * @param repo. point to the tsdbrepo + * @param totalPoints. total data point written + * @param totalStorage. total bytes took by the tsdb + * @param compStorage. total bytes took by the tsdb after compressed + */ +void tsdbReportStat(void *repo, int64_t *totalPoints, int64_t *totalStorage, int64_t *compStorage); + #ifdef __cplusplus } #endif diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index e06778a872..5926f2f243 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -357,6 +357,8 @@ typedef struct STsdbRepo { STsdbAppH appH; + STsdbStat stat; + // The meter meta handle of this TSDB repository STsdbMeta *tsdbMeta; diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 5e32a9e7d7..5526ad0d6e 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -953,6 +953,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY now, int32_t *affectedrows) { STsdbRepo *pRepo = (STsdbRepo *)repo; STsdbMeta *pMeta = pRepo->tsdbMeta; + int64_t points = 0; STableId tableId = {.uid = pBlock->uid, .tid = pBlock->tid}; STable *pTable = tsdbIsValidTableToInsert(pRepo->tsdbMeta, tableId); @@ -964,7 +965,9 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY // Check schema version int32_t tversion = pBlock->sversion; - int16_t nversion = schemaVersion(tsdbGetTableSchema(pMeta, pTable)); + STSchema * pSchema = tsdbGetTableSchema(pMeta, pTable); + ASSERT(pSchema != NULL); + int16_t nversion = schemaVersion(pSchema); if (tversion > nversion) { tsdbTrace("vgId:%d table:%s tid:%d server schema version %d is older than clien version %d, try to config.", pRepo->config.tsdbId, varDataVal(pTable->name), pTable->tableId.tid, nversion, tversion); @@ -1014,7 +1017,10 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY return -1; } (*affectedrows)++; + points++; } + atomic_fetch_add_64(&(pRepo->stat.pointsWritten), points * (pSchema->numOfCols)); + atomic_fetch_add_64(&(pRepo->stat.totalStorage), points * pSchema->vlen); return TSDB_CODE_SUCCESS; } @@ -1381,3 +1387,11 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t return magic; } + +void tsdbReportStat(void *repo, int64_t *totalPoints, int64_t *totalStorage, int64_t *compStorage){ + ASSERT(repo != NULL); + STsdbRepo * pRepo = repo; + *totalPoints = pRepo->stat.pointsWritten; + *totalStorage = pRepo->stat.totalStorage; + *compStorage = pRepo->stat.compStorage; +} \ No newline at end of file diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index af7f764717..7c95e81cf5 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -39,9 +39,6 @@ typedef struct { int8_t role; int64_t version; // current version int64_t fversion; // version on saved data file - int64_t totalStorage; //total bytes occupie - int64_t compStorage; - int64_t pointsWritten; //total data points written void *wqueue; void *rqueue; void *wal; diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 256ef3c72b..59f2a21b37 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -371,16 +371,18 @@ void *vnodeGetWal(void *pVnode) { static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SDMStatusMsg *pStatus) { if (pVnode->status == TAOS_VN_STATUS_DELETING) return; if (pStatus->openVnodes >= TSDB_MAX_VNODES) return; + int64_t totalStorage, compStorage, pointsWritten = 0; + tsdbReportStat(pVnode->tsdb, &pointsWritten, &totalStorage, &compStorage); SVnodeLoad *pLoad = &pStatus->load[pStatus->openVnodes++]; pLoad->vgId = htonl(pVnode->vgId); pLoad->cfgVersion = htonl(pVnode->cfgVersion); - pLoad->totalStorage = htobe64(pLoad->totalStorage); - pLoad->compStorage = htobe64(pLoad->compStorage); - pLoad->pointsWritten = htobe64(pLoad->pointsWritten); + pLoad->totalStorage = htobe64(totalStorage); + pLoad->compStorage = htobe64(compStorage); + pLoad->pointsWritten = htobe64(pointsWritten); pLoad->status = pVnode->status; pLoad->role = pVnode->role; - pLoad->replica = pVnode->syncCfg.replica; + pLoad->replica = pVnode->syncCfg.replica; } void vnodeBuildStatusMsg(void *param) { From 18c92c1cf4d7573210f866457428dd7bff13a9e0 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 9 Jun 2020 04:16:09 +0000 Subject: [PATCH 3/7] [TD-188] adjust format and remove some unnecessary code --- src/common/inc/tdataformat.h | 4 ++-- src/common/src/tdataformat.c | 4 ---- src/inc/tsdb.h | 8 ++++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 441af9a215..e1f17b09a9 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -69,8 +69,8 @@ typedef struct { int version; // version int numOfCols; // Number of columns appended int tlen; // maximum length of a SDataRow without the header part - int16_t flen; // First part length in a SDataRow after the header part - int16_t vlen; // pure value part length, excluded the overhead + int16_t flen; // First part length in a SDataRow after the header part + int16_t vlen; // pure value part length, excluded the overhead STColumn columns[]; } STSchema; diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index cb84c376eb..0e4ffda78b 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -37,7 +37,6 @@ void *tdEncodeSchema(void *dst, STSchema *pSchema) { T_APPEND_MEMBER(dst, pSchema, STSchema, version); T_APPEND_MEMBER(dst, pSchema, STSchema, numOfCols); - T_APPEND_MEMBER(dst, pSchema, STSchema, vlen); for (int i = 0; i < schemaNCols(pSchema); i++) { STColumn *pCol = schemaColAt(pSchema, i); T_APPEND_MEMBER(dst, pCol, STColumn, type); @@ -54,12 +53,10 @@ void *tdEncodeSchema(void *dst, STSchema *pSchema) { STSchema *tdDecodeSchema(void **psrc) { int totalCols = 0; int version = 0; - int16_t vlen = 0; STSchemaBuilder schemaBuilder = {0}; T_READ_MEMBER(*psrc, int, version); T_READ_MEMBER(*psrc, int, totalCols); - T_READ_MEMBER(*psrc, int16_t, vlen); if (tdInitTSchemaBuilder(&schemaBuilder, version) < 0) return NULL; @@ -78,7 +75,6 @@ STSchema *tdDecodeSchema(void **psrc) { } STSchema *pSchema = tdGetSchemaFromBuilder(&schemaBuilder); - pSchema->vlen = vlen; tdDestroyTSchemaBuilder(&schemaBuilder); return pSchema; } diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index bdb61e6ee1..add85d9438 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -67,10 +67,10 @@ typedef struct { // --------- TSDB REPOSITORY USAGE STATISTICS typedef struct { - int64_t totalStorage; //total bytes occupie - int64_t compStorage; - int64_t pointsWritten; //total data points written -}STsdbStat; + int64_t totalStorage; // total bytes occupie + int64_t compStorage; + int64_t pointsWritten; // total data points written +} STsdbStat; typedef void TsdbRepoT; // use void to hide implementation details from outside From ba19c379693f838a197f2772ae152e1c99d6954b Mon Sep 17 00:00:00 2001 From: Hui Li Date: Tue, 9 Jun 2020 14:06:06 +0800 Subject: [PATCH 4/7] [add cluster sim cases] --- .../arbitrator/sync_replica2_dropDb.sim | 189 +++++++++++++++++ .../arbitrator/sync_replica2_dropTable.sim | 199 ++++++++++++++++++ .../arbitrator/sync_replica3_dropDb.sim | 189 +++++++++++++++++ .../arbitrator/sync_replica3_dropTable.sim | 199 ++++++++++++++++++ .../sync_replica_dropDb_background.sim | 6 + .../sync_replica_dropTable_background.sim | 18 ++ 6 files changed, 800 insertions(+) create mode 100644 tests/script/unique/arbitrator/sync_replica2_dropDb.sim create mode 100644 tests/script/unique/arbitrator/sync_replica2_dropTable.sim create mode 100644 tests/script/unique/arbitrator/sync_replica3_dropDb.sim create mode 100644 tests/script/unique/arbitrator/sync_replica3_dropTable.sim create mode 100644 tests/script/unique/arbitrator/sync_replica_dropDb_background.sim create mode 100644 tests/script/unique/arbitrator/sync_replica_dropTable_background.sim diff --git a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim new file mode 100644 index 0000000000..fa19917e9f --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim @@ -0,0 +1,189 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c alternativeRole -v 1 +system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 3000 + +$totalTableNum = 100 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 maxTables $totalTableNum +sql create database $db replica 2 maxTables $totalTableNum +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +wait_dnode4_offline_0: +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +wait_dnode4_vgroup_offline: +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data4_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while drop database in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_dropDb_background.sim + +print ============== step6: check result +$cnt = 0 +wait_database_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show databases +if $rows != 0 then + sleep 2000 + goto wait_database_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim new file mode 100644 index 0000000000..cca4586b35 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim @@ -0,0 +1,199 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c alternativeRole -v 1 +system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 3000 + +$totalTableNum = 100 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 maxTables $totalTableNum +sql create database $db replica 2 maxTables $totalTableNum +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +wait_dnode4_offline_0: +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode4Status = $data4_3 +#$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +wait_dnode4_vgroup_offline: +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data4_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while drop database in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_dropTable_background.sim + +print ============== step6: check result +#in background.sim, drop 10 tables +$totalRows = $totalRows - 10800 + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 + sleep 2000 + goto wait_table_dropped +endi + +$tblNum = $tblNum - 10 +sql select count(tbname) from $stb +if $data00 != $tblNum then + print data00: $data00 + sleep 2000 + goto wait_table_dropped +endi + + diff --git a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim new file mode 100644 index 0000000000..e73291d6f3 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim @@ -0,0 +1,189 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c alternativeRole -v 1 +system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 3000 + +$totalTableNum = 100 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 maxTables $totalTableNum +sql create database $db replica 3 maxTables $totalTableNum +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +wait_dnode4_offline_0: +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +wait_dnode4_vgroup_offline: +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data4_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while drop database in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_dropDb_background.sim + +print ============== step6: check result +$cnt = 0 +wait_database_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show databases +if $rows != 0 then + sleep 2000 + goto wait_database_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim new file mode 100644 index 0000000000..20d157eeb5 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim @@ -0,0 +1,199 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c alternativeRole -v 1 +system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 3000 + +$totalTableNum = 100 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 maxTables $totalTableNum +sql create database $db replica 3 maxTables $totalTableNum +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +wait_dnode4_offline_0: +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +wait_dnode4_vgroup_offline: +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data4_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while drop database in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_dropTable_background.sim + +print ============== step6: check result +#in background.sim, drop 10 tables +$totalRows = $totalRows - 10800 + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 + sleep 2000 + goto wait_table_dropped +endi + +$tblNum = $tblNum - 10 +sql select count(tbname) from $stb +if $data00 != $tblNum then + print data00: $data00 + sleep 2000 + goto wait_table_dropped +endi + + diff --git a/tests/script/unique/arbitrator/sync_replica_dropDb_background.sim b/tests/script/unique/arbitrator/sync_replica_dropDb_background.sim new file mode 100644 index 0000000000..440b525bd7 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica_dropDb_background.sim @@ -0,0 +1,6 @@ +sql connect + +$db = db +$stb = stb +print =============== sync_replica_dropDb_background.sim step0: drop db +sql drop database if exists $db diff --git a/tests/script/unique/arbitrator/sync_replica_dropTable_background.sim b/tests/script/unique/arbitrator/sync_replica_dropTable_background.sim new file mode 100644 index 0000000000..a52cecaa8e --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica_dropTable_background.sim @@ -0,0 +1,18 @@ +sql connect + +$db = db +$stb = stb +print =============== sync_replica_dropTable_background.sim step0: drop table +$totalTableNum = 100 + +sql use $db + +$tblNum = $totalTableNum +$dropTblNum = 11 + +$i = 1 +while $i < $dropTblNum + $tb = tb . $i + sql drop table if exists $tb + $i = $i + 1 +endw From c7813ea59bb94c23aff67a6eef65e660fbcc5b21 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Tue, 9 Jun 2020 15:54:07 +0800 Subject: [PATCH 5/7] =?UTF-8?q?TD-556:=20Stream=E6=B5=8B=E8=AF=95=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=88=B0=E5=B8=B8=E8=A7=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/pytest/fulltest.sh | 4 ++++ tests/pytest/regressiontest.sh | 11 ++++++++--- tests/script/fullGeneralSuite.sim | 12 ++++++++++++ tests/script/regressionSuite.sim | 11 +++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 99dc658d71..a157100236 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -134,3 +134,7 @@ python3 ./test.py -f query/filter.py python3 ./test.py -f query/filterCombo.py python3 ./test.py -f query/queryNormal.py python3 ./test.py -f query/queryError.py + +#stream +python3 ./test.py -f stream/stream1.py +python3 ./test.py -f stream/stream2.py diff --git a/tests/pytest/regressiontest.sh b/tests/pytest/regressiontest.sh index e1d4c6348b..61407b49e3 100755 --- a/tests/pytest/regressiontest.sh +++ b/tests/pytest/regressiontest.sh @@ -131,6 +131,11 @@ python3 ./test.py -f user/pass_len.py #query python3 ./test.py -f query/filter.py -# python3 ./test.py -f query/filterCombo.py -# python3 ./test.py -f query/queryNormal.py -# python3 ./test.py -f query/queryError.py + + +#stream +python3 ./test.py -f stream/stream1.py +python3 ./test.py -f stream/stream2.py + + + diff --git a/tests/script/fullGeneralSuite.sim b/tests/script/fullGeneralSuite.sim index aa32fe4008..a7d6707e7d 100644 --- a/tests/script/fullGeneralSuite.sim +++ b/tests/script/fullGeneralSuite.sim @@ -211,3 +211,15 @@ run general/vector/table_field.sim run general/vector/table_mix.sim run general/vector/table_query.sim run general/vector/table_time.sim +run general/stream/stream_1.sim +run general/stream/stream_2.sim +run general/stream/stream_3.sim +run general/stream/stream_restart.sim +run general/stream/table_1.sim +run general/stream/metrics_1.sim +run general/stream/table_n.sim +run general/stream/metrics_n.sim +run general/stream/table_del.sim +run general/stream/metrics_del.sim +run general/stream/table_replica1_vnoden.sim +run general/stream/metrics_replica1_vnoden.sim diff --git a/tests/script/regressionSuite.sim b/tests/script/regressionSuite.sim index 67f54523df..683918ee54 100644 --- a/tests/script/regressionSuite.sim +++ b/tests/script/regressionSuite.sim @@ -211,3 +211,14 @@ run general/vector/table_field.sim run general/vector/table_mix.sim run general/vector/table_query.sim run general/vector/table_time.sim +run general/stream/stream_1.sim +run general/stream/stream_2.sim +run general/stream/stream_3.sim +run general/stream/table_1.sim +run general/stream/metrics_1.sim +run general/stream/table_n.sim +run general/stream/metrics_n.sim +run general/stream/table_del.sim +run general/stream/metrics_del.sim +run general/stream/table_replica1_vnoden.sim +run general/stream/metrics_replica1_vnoden.sim From 53683446d65766073c365787fa68a10d58645ab5 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 9 Jun 2020 16:16:53 +0800 Subject: [PATCH 6/7] fix random-test delete datafiles bug. --- tests/pytest/random-test/random-test-multi-threading-3.py | 3 ++- tests/pytest/random-test/random-test-multi-threading.py | 2 +- tests/pytest/random-test/random-test.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/pytest/random-test/random-test-multi-threading-3.py b/tests/pytest/random-test/random-test-multi-threading-3.py index cab17c4c1a..91f35ea7a5 100644 --- a/tests/pytest/random-test/random-test-multi-threading-3.py +++ b/tests/pytest/random-test/random-test-multi-threading-3.py @@ -205,6 +205,7 @@ class Test (Thread): global written dnodesDir = tdDnodes.getDnodesRootDir() + tdDnodes.forcestop(1) dataDir = dnodesDir + '/dnode1/data/*' deleteCmd = 'rm -rf %s' % dataDir os.system(deleteCmd) @@ -261,7 +262,7 @@ class Test (Thread): while True: self.queryEvent.wait() tdLog.notice("third thread") - randQueryOp = random.randint(1, 9) + randQueryOp = random.randint(1, 2) queryOp.get(randQueryOp, lambda: "ERROR")() self.queryEvent.clear() self.dbEvent.clear() diff --git a/tests/pytest/random-test/random-test-multi-threading.py b/tests/pytest/random-test/random-test-multi-threading.py index 1d8a5c3c82..997001157e 100644 --- a/tests/pytest/random-test/random-test-multi-threading.py +++ b/tests/pytest/random-test/random-test-multi-threading.py @@ -208,12 +208,12 @@ class Test (threading.Thread): global written dnodesDir = tdDnodes.getDnodesRootDir() + tdDnodes.forcestop(1) dataDir = dnodesDir + '/dnode1/data/*' deleteCmd = 'rm -rf %s' % dataDir os.system(deleteCmd) tdDnodes.start(1) -# tdLog.sleep(10) tdSql.prepare() last_tb = "" last_stb = "" diff --git a/tests/pytest/random-test/random-test.py b/tests/pytest/random-test/random-test.py index 855cabdedd..9cfc24f404 100644 --- a/tests/pytest/random-test/random-test.py +++ b/tests/pytest/random-test/random-test.py @@ -166,7 +166,8 @@ class Test: def delete_datafiles(self): tdLog.info("delete_datafiles") dnodesDir = tdDnodes.getDnodesRootDir() - dataDir = dnodesDir + '/dnode1/*' + tdDnodes.forcestop(1) + dataDir = dnodesDir + '/dnode1/data/*' deleteCmd = 'rm -rf %s' % dataDir os.system(deleteCmd) From 5d0cc08e9a0e2c5020cd8a12b180d1b3aef7ada4 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 9 Jun 2020 08:52:36 +0000 Subject: [PATCH 7/7] [TD_543] fix coverity scan, cid:290455 286428 286450 287977 287995 290226 --- src/dnode/src/dnodeMain.c | 8 +++----- src/dnode/src/dnodeMgmt.c | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 73bc2923b2..91f146dde4 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -61,12 +61,10 @@ static const SDnodeComponent tsDnodeComponents[] = { }; static int dnodeCreateDir(const char *dir) { - struct stat dirstat; - if (stat(dir, &dirstat) < 0) { - if (mkdir(dir, 0755) != 0 && errno != EEXIST) { - return -1; - } + if (mkdir(dir, 0755) != 0 && errno != EEXIST) { + return -1; } + return 0; } diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index 4b448837fe..e260e7ec81 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -177,10 +177,12 @@ void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) { memcpy(item, pMsg, sizeof(SRpcMsg)); taosWriteQitem(tsMgmtQueue, 1, item); } else { - SRpcMsg rsp; - rsp.handle = pMsg->handle; - rsp.pCont = NULL; - rsp.code = TSDB_CODE_DND_OUT_OF_MEMORY; + SRpcMsg rsp = { + .handle = pMsg->handle, + .pCont = NULL, + .code = TSDB_CODE_DND_OUT_OF_MEMORY + }; + rpcSendResponse(&rsp); rpcFreeCont(pMsg->pCont); } @@ -188,9 +190,9 @@ void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) { static void *dnodeProcessMgmtQueue(void *param) { SRpcMsg *pMsg; - SRpcMsg rsp; + SRpcMsg rsp = {0}; int type; - void *handle; + void * handle; while (1) { if (taosReadQitemFromQset(tsMgmtQset, &type, (void **) &pMsg, &handle) == 0) { @@ -251,6 +253,7 @@ static int32_t dnodeOpenVnodes() { if (status != TSDB_CODE_SUCCESS) { dPrint("Get dnode list failed"); + free(vnodeList); return status; } @@ -290,6 +293,7 @@ static void dnodeCloseVnodes() { if (status != TSDB_CODE_SUCCESS) { dPrint("Get dnode list failed"); + free(vnodeList); return; } @@ -456,6 +460,7 @@ static bool dnodeReadMnodeInfos() { return false; } + content[len] = 0; cJSON* root = cJSON_Parse(content); if (root == NULL) { dError("failed to read mnodeIpList.json, invalid json format"); @@ -628,6 +633,7 @@ static bool dnodeReadDnodeCfg() { return false; } + content[len] = 0; cJSON* root = cJSON_Parse(content); if (root == NULL) { dError("failed to read dnodeCfg.json, invalid json format");