[TD-3963]handle oom in tsdbExpendPool
This commit is contained in:
parent
dffd44c6c6
commit
d9127c0501
|
@ -40,7 +40,7 @@ void tsdbFreeBufPool(STsdbBufPool* pBufPool);
|
||||||
int tsdbOpenBufPool(STsdbRepo* pRepo);
|
int tsdbOpenBufPool(STsdbRepo* pRepo);
|
||||||
void tsdbCloseBufPool(STsdbRepo* pRepo);
|
void tsdbCloseBufPool(STsdbRepo* pRepo);
|
||||||
SListNode* tsdbAllocBufBlockFromPool(STsdbRepo* pRepo);
|
SListNode* tsdbAllocBufBlockFromPool(STsdbRepo* pRepo);
|
||||||
void tsdbExpendPool(STsdbRepo* pRepo, int32_t oldTotalBlocks);
|
int tsdbExpendPool(STsdbRepo* pRepo, int32_t oldTotalBlocks);
|
||||||
void tsdbRecycleBufferBlock(STsdbBufPool* pPool, SListNode *pNode);
|
void tsdbRecycleBufferBlock(STsdbBufPool* pPool, SListNode *pNode);
|
||||||
|
|
||||||
#endif /* _TD_TSDB_BUFFER_H_ */
|
#endif /* _TD_TSDB_BUFFER_H_ */
|
|
@ -159,12 +159,14 @@ _err:
|
||||||
|
|
||||||
static void tsdbFreeBufBlock(STsdbBufBlock *pBufBlock) { tfree(pBufBlock); }
|
static void tsdbFreeBufBlock(STsdbBufBlock *pBufBlock) { tfree(pBufBlock); }
|
||||||
|
|
||||||
void tsdbExpendPool(STsdbRepo* pRepo, int32_t oldTotalBlocks) {
|
int tsdbExpendPool(STsdbRepo* pRepo, int32_t oldTotalBlocks) {
|
||||||
if (oldTotalBlocks == pRepo->config.totalBlocks) {
|
if (oldTotalBlocks == pRepo->config.totalBlocks) {
|
||||||
return;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsdbLockRepo(pRepo) < 0) return;
|
int err = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
if (tsdbLockRepo(pRepo) < 0) return terrno;
|
||||||
STsdbBufPool* pPool = pRepo->pPool;
|
STsdbBufPool* pPool = pRepo->pPool;
|
||||||
|
|
||||||
if (pRepo->config.totalBlocks > oldTotalBlocks) {
|
if (pRepo->config.totalBlocks > oldTotalBlocks) {
|
||||||
|
@ -175,6 +177,7 @@ void tsdbExpendPool(STsdbRepo* pRepo, int32_t oldTotalBlocks) {
|
||||||
if (tdListAppend(pPool->bufBlockList, (void *)(&pBufBlock)) < 0) {
|
if (tdListAppend(pPool->bufBlockList, (void *)(&pBufBlock)) < 0) {
|
||||||
tsdbFreeBufBlock(pBufBlock);
|
tsdbFreeBufBlock(pBufBlock);
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
err = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +190,7 @@ void tsdbExpendPool(STsdbRepo* pRepo, int32_t oldTotalBlocks) {
|
||||||
|
|
||||||
err:
|
err:
|
||||||
tsdbUnlockRepo(pRepo);
|
tsdbUnlockRepo(pRepo);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbRecycleBufferBlock(STsdbBufPool* pPool, SListNode *pNode) {
|
void tsdbRecycleBufferBlock(STsdbBufPool* pPool, SListNode *pNode) {
|
||||||
|
|
|
@ -130,7 +130,11 @@ static void tsdbApplyRepoConfig(STsdbRepo *pRepo) {
|
||||||
pSaveCfg->compression, pSaveCfg->keep,pSaveCfg->keep1, pSaveCfg->keep2,
|
pSaveCfg->compression, pSaveCfg->keep,pSaveCfg->keep1, pSaveCfg->keep2,
|
||||||
pSaveCfg->totalBlocks, pSaveCfg->cacheLastRow, pSaveCfg->totalBlocks);
|
pSaveCfg->totalBlocks, pSaveCfg->cacheLastRow, pSaveCfg->totalBlocks);
|
||||||
|
|
||||||
tsdbExpendPool(pRepo, oldTotalBlocks);
|
int err = tsdbExpendPool(pRepo, oldTotalBlocks);
|
||||||
|
if (!TAOS_SUCCEEDED(err)) {
|
||||||
|
tsdbError("vgId:%d expand pool from %d to %d fail,reason:%s",
|
||||||
|
REPO_ID(pRepo), oldTotalBlocks, pSaveCfg->totalBlocks, tstrerror(err));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue