Unverified Commit ae6df30e authored by Moti Cohen's avatar Moti Cohen Committed by GitHub
Browse files

Fix ebuckets stop indication during ebExpire() (#13287)

on active-expire of buckets, at function `ebExpire()` ->
`ebSegExpire()`, if callback `onExpireItem()` indicated to stop, Yet
iterator (iter) was wrongly already got updated to point to next item.
In turn the segment will be updated without current item.
parent a25b1539
...@@ -436,10 +436,11 @@ static int ebSegExpire(FirstSegHdr *firstSegHdr, ...@@ -436,10 +436,11 @@ static int ebSegExpire(FirstSegHdr *firstSegHdr,
for (i = 0; (i < numItemsInSeg) && (info->itemsExpired < info->maxToExpire) ; ++i) { for (i = 0; (i < numItemsInSeg) && (info->itemsExpired < info->maxToExpire) ; ++i) {
mIter = type->getExpireMeta(iter); mIter = type->getExpireMeta(iter);
eItem toDelete = iter;
iter = mIter->next; /* keep aside `next` before removing `iter` by onExpireItem */
eItem next = mIter->next;
mIter->trash = 1; mIter->trash = 1;
ExpireAction act = info->onExpireItem(toDelete, info->ctx); ExpireAction act = info->onExpireItem(iter, info->ctx);
/* if (act == ACT_REMOVE_EXP_ITEM) /* if (act == ACT_REMOVE_EXP_ITEM)
* then don't touch the item. Assume it got deleted */ * then don't touch the item. Assume it got deleted */
...@@ -452,9 +453,11 @@ static int ebSegExpire(FirstSegHdr *firstSegHdr, ...@@ -452,9 +453,11 @@ static int ebSegExpire(FirstSegHdr *firstSegHdr,
if (act == ACT_UPDATE_EXP_ITEM) { if (act == ACT_UPDATE_EXP_ITEM) {
mIter->next = *updateList; mIter->next = *updateList;
*updateList = toDelete; *updateList = iter;
} }
/* Item was REMOVED/UPDATED. Advance to `next` item */
iter = next;
++info->itemsExpired; ++info->itemsExpired;
firstSegHdr->totalItems -= 1; firstSegHdr->totalItems -= 1;
} }
...@@ -672,6 +675,7 @@ static int ebListExpire(ebuckets *eb, ...@@ -672,6 +675,7 @@ static int ebListExpire(ebuckets *eb,
if (info->itemsExpired == info->maxToExpire) if (info->itemsExpired == info->maxToExpire)
break; break;
/* keep aside `next` before removing `iter` by onExpireItem */
eItem *next = metaItem->next; eItem *next = metaItem->next;
metaItem->trash = 1; metaItem->trash = 1;
ExpireAction act = info->onExpireItem(item, info->ctx); ExpireAction act = info->onExpireItem(item, info->ctx);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment