Merge pull request #2756 from taosdata/bugfix/alloc-fail
TD-905: fix some crash when memory allocation fail
This commit is contained in:
commit
69b8be6638
|
@ -1454,6 +1454,9 @@ static int32_t mnodeSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pT
|
||||||
static int32_t mnodeGetSuperTableMeta(SMnodeMsg *pMsg) {
|
static int32_t mnodeGetSuperTableMeta(SMnodeMsg *pMsg) {
|
||||||
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
|
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
|
||||||
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16));
|
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16));
|
||||||
|
if (pMeta == NULL) {
|
||||||
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
pMeta->uid = htobe64(pTable->uid);
|
pMeta->uid = htobe64(pTable->uid);
|
||||||
pMeta->sversion = htons(pTable->sversion);
|
pMeta->sversion = htons(pTable->sversion);
|
||||||
pMeta->tversion = htons(pTable->tversion);
|
pMeta->tversion = htons(pTable->tversion);
|
||||||
|
|
|
@ -5913,8 +5913,10 @@ _cleanup_qinfo:
|
||||||
tsdbDestroyTableGroup(pTableGroupInfo);
|
tsdbDestroyTableGroup(pTableGroupInfo);
|
||||||
|
|
||||||
_cleanup_query:
|
_cleanup_query:
|
||||||
taosArrayDestroy(pGroupbyExpr->columnInfo);
|
if (pGroupbyExpr != NULL) {
|
||||||
tfree(pGroupbyExpr);
|
taosArrayDestroy(pGroupbyExpr->columnInfo);
|
||||||
|
free(pGroupbyExpr);
|
||||||
|
}
|
||||||
tfree(pTagCols);
|
tfree(pTagCols);
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SExprInfo* pExprInfo = &pExprs[i];
|
SExprInfo* pExprInfo = &pExprs[i];
|
||||||
|
|
|
@ -41,6 +41,9 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
|
||||||
pWindowResInfo->type = type;
|
pWindowResInfo->type = type;
|
||||||
_hash_fn_t fn = taosGetDefaultHashFunction(type);
|
_hash_fn_t fn = taosGetDefaultHashFunction(type);
|
||||||
pWindowResInfo->hashList = taosHashInit(threshold, fn, false);
|
pWindowResInfo->hashList = taosHashInit(threshold, fn, false);
|
||||||
|
if (pWindowResInfo->hashList == NULL) {
|
||||||
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
pWindowResInfo->curIndex = -1;
|
pWindowResInfo->curIndex = -1;
|
||||||
pWindowResInfo->size = 0;
|
pWindowResInfo->size = 0;
|
||||||
|
|
|
@ -1218,7 +1218,9 @@ static void *tsdbInsertTableAct(STsdbRepo *pRepo, int8_t act, void *buf, STable
|
||||||
static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) {
|
static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) {
|
||||||
int tlen = tsdbGetTableEncodeSize(TSDB_DROP_META, pTable);
|
int tlen = tsdbGetTableEncodeSize(TSDB_DROP_META, pTable);
|
||||||
void *buf = tsdbAllocBytes(pRepo, tlen);
|
void *buf = tsdbAllocBytes(pRepo, tlen);
|
||||||
ASSERT(buf != NULL);
|
if (buf == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void *pBuf = buf;
|
void *pBuf = buf;
|
||||||
if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
|
if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
|
||||||
|
|
|
@ -175,6 +175,9 @@ static SArray* getDefaultLoadColumns(STsdbQueryHandle* pQueryHandle, bool loadTS
|
||||||
|
|
||||||
TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, void* qinfo) {
|
TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, void* qinfo) {
|
||||||
STsdbQueryHandle* pQueryHandle = calloc(1, sizeof(STsdbQueryHandle));
|
STsdbQueryHandle* pQueryHandle = calloc(1, sizeof(STsdbQueryHandle));
|
||||||
|
if (pQueryHandle == NULL) {
|
||||||
|
goto out_of_memory;
|
||||||
|
}
|
||||||
pQueryHandle->order = pCond->order;
|
pQueryHandle->order = pCond->order;
|
||||||
pQueryHandle->window = pCond->twindow;
|
pQueryHandle->window = pCond->twindow;
|
||||||
pQueryHandle->pTsdb = tsdb;
|
pQueryHandle->pTsdb = tsdb;
|
||||||
|
@ -260,8 +263,8 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
|
||||||
return (TsdbQueryHandleT) pQueryHandle;
|
return (TsdbQueryHandleT) pQueryHandle;
|
||||||
|
|
||||||
out_of_memory:
|
out_of_memory:
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
|
||||||
tsdbCleanupQueryHandle(pQueryHandle);
|
tsdbCleanupQueryHandle(pQueryHandle);
|
||||||
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue