fix(tdb): restrict tdb allocation from buffer pool
This commit is contained in:
parent
e966df59e8
commit
a94d6aef03
|
@ -14,10 +14,19 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
#include "vnd.h"
|
||||||
|
|
||||||
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) {
|
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) {
|
||||||
|
SVBufPool *pool = (SVBufPool *)pPool;
|
||||||
|
SVnode *pVnode = pool->pVnode;
|
||||||
|
|
||||||
|
if (pVnode->inUse && pVnode->inUse->size > pVnode->inUse->node.size) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
|
return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||||
|
|
||||||
// begin a meta txn
|
// begin a meta txn
|
||||||
|
|
|
@ -345,7 +345,9 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn)
|
||||||
if (!pPage && pTxn->xMalloc != NULL) {
|
if (!pPage && pTxn->xMalloc != NULL) {
|
||||||
ret = tdbPageCreate(pCache->szPage, &pPage, pTxn->xMalloc, pTxn->xArg);
|
ret = tdbPageCreate(pCache->szPage, &pPage, pTxn->xMalloc, pTxn->xArg);
|
||||||
if (ret < 0 || pPage == NULL) {
|
if (ret < 0 || pPage == NULL) {
|
||||||
tdbError("tdb/pcache: ret: %" PRId32 " pPage: %p, page create failed.", ret, pPage);
|
// when allocating from bufpool failed, it's time to flush cache.
|
||||||
|
// tdbError("tdb/pcache: ret: %" PRId32 " pPage: %p, page create failed.", ret, pPage);
|
||||||
|
|
||||||
terrno = ret;
|
terrno = ret;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -551,5 +553,4 @@ static void tdbPCacheCloseImpl(SPCache *pCache) {
|
||||||
|
|
||||||
tdbOsFree(pCache->pgHash);
|
tdbOsFree(pCache->pgHash);
|
||||||
tdbPCacheDestroyLock(pCache);
|
tdbPCacheDestroyLock(pCache);
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
ret = tdbPagerRestoreJournals(pPager);
|
ret = tdbPagerRestoreJournals(pPager);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -118,6 +118,13 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
// Always restore journal files with page flushing
|
||||||
|
ret = tdbPagerRestoreJournals(pPager);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbOsFree(pTb);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// pTb->pBt
|
// pTb->pBt
|
||||||
ret = tdbBtreeOpen(keyLen, valLen, pPager, tbname, pgno, keyCmprFn, pEnv, &(pTb->pBt));
|
ret = tdbBtreeOpen(keyLen, valLen, pPager, tbname, pgno, keyCmprFn, pEnv, &(pTb->pBt));
|
||||||
|
|
|
@ -18,3 +18,6 @@ target_link_libraries(tdbPageDefragmentTest tdb gtest gtest_main)
|
||||||
add_executable(tdbPageRecycleTest "tdbPageRecycleTest.cpp")
|
add_executable(tdbPageRecycleTest "tdbPageRecycleTest.cpp")
|
||||||
target_link_libraries(tdbPageRecycleTest tdb gtest gtest_main)
|
target_link_libraries(tdbPageRecycleTest tdb gtest gtest_main)
|
||||||
|
|
||||||
|
# page flush testing
|
||||||
|
add_executable(tdbPageFlushTest "tdbPageFlushTest.cpp")
|
||||||
|
target_link_libraries(tdbPageFlushTest tdb gtest gtest_main)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue