未验证 提交 8fb051e1 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #16936 from taosdata/fix/TD-19127

fix: update dbOrigSize before releasing dirty pages
...@@ -248,6 +248,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { ...@@ -248,6 +248,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
return 0; return 0;
} }
// loop to write the dirty pages to file
SRBTreeIter iter = tRBTreeIterCreate(&pPager->rbt, 1); SRBTreeIter iter = tRBTreeIterCreate(&pPager->rbt, 1);
SRBTreeNode *pNode = NULL; SRBTreeNode *pNode = NULL;
while ((pNode = tRBTreeIterNext(&iter)) != NULL) { while ((pNode = tRBTreeIterNext(&iter)) != NULL) {
...@@ -257,37 +258,23 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { ...@@ -257,37 +258,23 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
ASSERT(0); ASSERT(0);
return -1; return -1;
} }
pPage->isDirty = 0;
tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage);
tdbPCacheRelease(pPager->pCache, pPage, pTxn);
} }
tRBTreeCreate(&pPager->rbt, pageCmpFn); tdbTrace("tdbttl commit:%p, %d/%d", pPager, pPager->dbOrigSize, pPager->dbFileSize);
/* pPager->dbOrigSize = pPager->dbFileSize;
// loop to write the dirty pages to file
for (pPage = pPager->pDirty; pPage; pPage = pPage->pDirtyNext) {
// TODO: update the page footer
ret = tdbPagerWritePageToDB(pPager, pPage);
if (ret < 0) {
ASSERT(0);
return -1;
}
}
// release the page // release the page
for (pPage = pPager->pDirty; pPage; pPage = pPager->pDirty) { iter = tRBTreeIterCreate(&pPager->rbt, 1);
pPager->pDirty = pPage->pDirtyNext; while ((pNode = tRBTreeIterNext(&iter)) != NULL) {
pPage->pDirtyNext = NULL; pPage = (SPage *)pNode;
pPage->isDirty = 0; pPage->isDirty = 0;
tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage);
tdbPCacheRelease(pPager->pCache, pPage, pTxn); tdbPCacheRelease(pPager->pCache, pPage, pTxn);
} }
*/
tdbTrace("tdbttl commit:%p, %d", pPager, pPager->dbOrigSize); tRBTreeCreate(&pPager->rbt, pageCmpFn);
pPager->dbOrigSize = pPager->dbFileSize;
// sync the db file // sync the db file
tdbOsFSync(pPager->fd); tdbOsFSync(pPager->fd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册