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

Merge pull request #18434 from taosdata/fix/TD-20647

fix(tdb): zero pOlds[i]'s nOverflow and assert it's zero when committing
...@@ -741,14 +741,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx ...@@ -741,14 +741,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL); tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
tdbBtreeInitPage(pOldsCopy[i], &iarg, 0); tdbBtreeInitPage(pOldsCopy[i], &iarg, 0);
tdbPageCopy(pOlds[i], pOldsCopy[i], 0); tdbPageCopy(pOlds[i], pOldsCopy[i], 0);
} pOlds[i]->nOverflow = 0;
for (iNew = 0; iNew < nNews; ++iNew) {
tdbBtreeInitPage(pNews[iNew], &iarg, 0);
} }
iNew = 0; iNew = 0;
nNewCells = 0; nNewCells = 0;
tdbBtreeInitPage(pNews[iNew], &iarg, 0);
for (int iOld = 0; iOld < nOlds; iOld++) { for (int iOld = 0; iOld < nOlds; iOld++) {
SPage *pPage; SPage *pPage;
......
...@@ -68,7 +68,7 @@ void hashset_destroy(hashset_t set) { ...@@ -68,7 +68,7 @@ void hashset_destroy(hashset_t set) {
} }
int hashset_add_member(hashset_t set, void *item) { int hashset_add_member(hashset_t set, void *item) {
size_t value = (size_t) item; size_t value = (size_t)item;
size_t h; size_t h;
if (value == 0) { if (value == 0) {
...@@ -103,7 +103,7 @@ int hashset_add(hashset_t set, void *item) { ...@@ -103,7 +103,7 @@ int hashset_add(hashset_t set, void *item) {
set->nitems = 0; set->nitems = 0;
for (size_t i = 0; i < old_capacity; ++i) { for (size_t i = 0; i < old_capacity; ++i) {
hashset_add_member(set, (void*)old_items[i]); hashset_add_member(set, (void *)old_items[i]);
} }
tdbOsFree(old_items); tdbOsFree(old_items);
} }
...@@ -112,7 +112,7 @@ int hashset_add(hashset_t set, void *item) { ...@@ -112,7 +112,7 @@ int hashset_add(hashset_t set, void *item) {
} }
int hashset_remove(hashset_t set, void *item) { int hashset_remove(hashset_t set, void *item) {
size_t value = (size_t) item; size_t value = (size_t)item;
for (size_t h = set->mask & (prime * value); set->items[h] != 0; h = set->mask & (h + prime2)) { for (size_t h = set->mask & (prime * value); set->items[h] != 0; h = set->mask & (h + prime2)) {
if (set->items[h] == value) { if (set->items[h] == value) {
...@@ -126,7 +126,7 @@ int hashset_remove(hashset_t set, void *item) { ...@@ -126,7 +126,7 @@ int hashset_remove(hashset_t set, void *item) {
} }
int hashset_contains(hashset_t set, void *item) { int hashset_contains(hashset_t set, void *item) {
size_t value = (size_t) item; size_t value = (size_t)item;
for (size_t h = set->mask & (prime * value); set->items[h] != 0; h = set->mask & (h + prime2)) { for (size_t h = set->mask & (prime * value); set->items[h] != 0; h = set->mask & (h + prime2)) {
if (set->items[h] == value) { if (set->items[h] == value) {
...@@ -319,7 +319,8 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { ...@@ -319,7 +319,8 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
tRBTreePut(&pPager->rbt, (SRBTreeNode *)pPage); tRBTreePut(&pPager->rbt, (SRBTreeNode *)pPage);
// Write page to journal if neccessary // Write page to journal if neccessary
if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize && (pPager->jPageSet == NULL || !hashset_contains(pPager->jPageSet, (void*)((long)TDB_PAGE_PGNO(pPage))))) { if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize &&
(pPager->jPageSet == NULL || !hashset_contains(pPager->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))))) {
ret = tdbPagerWritePageToJournal(pPager, pPage); ret = tdbPagerWritePageToJournal(pPager, pPage);
if (ret < 0) { if (ret < 0) {
tdbError("failed to write page to journal since %s", tstrerror(terrno)); tdbError("failed to write page to journal since %s", tstrerror(terrno));
...@@ -327,7 +328,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { ...@@ -327,7 +328,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
} }
if (pPager->jPageSet) { if (pPager->jPageSet) {
hashset_add(pPager->jPageSet, (void*)((long)TDB_PAGE_PGNO(pPage))); hashset_add(pPager->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage)));
} }
} }
...@@ -372,6 +373,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { ...@@ -372,6 +373,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
SRBTreeNode *pNode = NULL; SRBTreeNode *pNode = NULL;
while ((pNode = tRBTreeIterNext(&iter)) != NULL) { while ((pNode = tRBTreeIterNext(&iter)) != NULL) {
pPage = (SPage *)pNode; pPage = (SPage *)pNode;
ASSERT(pPage->nOverflow == 0);
ret = tdbPagerWritePageToDB(pPager, pPage); ret = tdbPagerWritePageToDB(pPager, pPage);
if (ret < 0) { if (ret < 0) {
tdbError("failed to write page to db since %s", tstrerror(terrno)); tdbError("failed to write page to db since %s", tstrerror(terrno));
...@@ -391,7 +393,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { ...@@ -391,7 +393,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage);
if (pPager->jPageSet) { if (pPager->jPageSet) {
hashset_remove(pPager->jPageSet, (void*)((long)TDB_PAGE_PGNO(pPage))); hashset_remove(pPager->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage)));
} }
tdbPCacheRelease(pPager->pCache, pPage, pTxn); tdbPCacheRelease(pPager->pCache, pPage, pTxn);
} }
...@@ -560,7 +562,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { ...@@ -560,7 +562,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
pPage->isDirty = 0; pPage->isDirty = 0;
tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage);
hashset_remove(pPager->jPageSet, (void*)((long)TDB_PAGE_PGNO(pPage))); hashset_remove(pPager->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage)));
tdbPCacheRelease(pPager->pCache, pPage, pTxn); tdbPCacheRelease(pPager->pCache, pPage, pTxn);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册