From fc0cfd875b09d32f5700370aad4e21804913d90f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 3 Jun 2020 03:03:28 +0000 Subject: [PATCH] TD-90 --- src/tsdb/inc/tsdbMain.h | 1 + src/tsdb/src/tsdbMain.c | 27 ++++++++++++++++++++------- src/tsdb/src/tsdbMeta.c | 4 ++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index ded5f6eb36..c4e929e3cd 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 15a6ca2403..ee927d0ccd 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 3ea22f2b91..dcea9ac46b 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); } } -- GitLab