diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index ded5f6eb36df354c9501fc731c1271ea552f9b50..c4e929e3cd7dc4d4dac55b142d00092425e89d2d 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -506,6 +506,7 @@ int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks); void tsdbAdjustCacheBlocks(STsdbCache *pCache); int32_t tsdbGetMetaFileName(char *rootDir, char *fname); int tsdbUpdateFileHeader(SFile *pFile, uint32_t version); +int tsdbUpdateTable(STable *pTable, STableCfg *pCfg); #ifdef __cplusplus } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 15a6ca240359eed4fcf8a1ff2c68a046b1860cba..ee927d0ccd5544df6a9f19d997bbff1b0c5f0a3f 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -429,10 +429,20 @@ int tsdbUpdateTagValue(TsdbRepoT *repo, SUpdateTableTagValMsg *pMsg) { tsdbTrace("vgId:%d server tag version %d is older than client tag version %d, try to config", pRepo->config.tsdbId, schemaVersion(tsdbGetTableTagSchema(pMeta, pTable)), tversion); void *msg = (*pRepo->appH.configFunc)(pRepo->config.tsdbId, htonl(pMsg->tid)); + if (msg == NULL) { + return terrno; + } // Deal with error her STableCfg *pTableCfg = tsdbCreateTableCfgFromMsg(msg); + STable *super = tsdbGetTableByUid(pMeta, pTableCfg->superUid); + ASSERT(super != NULL); - ASSERT(pTableCfg != NULL); + int32_t code = tsdbUpdateTable(super, pTableCfg); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + tsdbClearTableCfg(pTableCfg); + rpcFreeCont(msg); } if (schemaVersion(tsdbGetTableTagSchema(pMeta, pTable)) > tversion) { @@ -595,12 +605,15 @@ int tsdbTableSetStreamSql(STableCfg *config, char *sql, bool dup) { } void tsdbClearTableCfg(STableCfg *config) { - if (config->schema) tdFreeSchema(config->schema); - if (config->tagSchema) tdFreeSchema(config->tagSchema); - if (config->tagValues) kvRowFree(config->tagValues); - tfree(config->name); - tfree(config->sname); - tfree(config->sql); + if (config) { + if (config->schema) tdFreeSchema(config->schema); + if (config->tagSchema) tdFreeSchema(config->tagSchema); + if (config->tagValues) kvRowFree(config->tagValues); + tfree(config->name); + tfree(config->sname); + tfree(config->sql); + free(config); + } } int tsdbInitSubmitBlkIter(SSubmitBlk *pBlock, SSubmitBlkIter *pIter) { diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 3ea22f2b91631881e8b5357e7df4b19669ac628f..dcea9ac46b817771d9110260d5301ff3c4243819 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -370,7 +370,7 @@ static int tsdbUpdateTableTagSchema(STable *pTable, STSchema *newSchema) { return TSDB_CODE_SUCCESS; } -static int tsdbCheckAndUpdateTable(STable *pTable, STableCfg *pCfg) { +int tsdbUpdateTable(STable *pTable, STableCfg *pCfg) { ASSERT(pTable->type != TSDB_CHILD_TABLE); if (pTable->type == TSDB_SUPER_TABLE) { @@ -411,7 +411,7 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { } else { if (super->type != TSDB_SUPER_TABLE) return -1; if (super->tableId.uid != pCfg->superUid) return -1; - tsdbCheckAndUpdateTable(super, pCfg); + tsdbUpdateTable(super, pCfg); } }