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.
This commit is contained in:
Moti Cohen 2024-05-23 10:46:50 +03:00 committed by GitHub
parent a25b15392c
commit ae6df30eb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -436,10 +436,11 @@ static int ebSegExpire(FirstSegHdr *firstSegHdr,
for (i = 0; (i < numItemsInSeg) && (info->itemsExpired < info->maxToExpire) ; ++i) {
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;
ExpireAction act = info->onExpireItem(toDelete, info->ctx);
ExpireAction act = info->onExpireItem(iter, info->ctx);
/* if (act == ACT_REMOVE_EXP_ITEM)
* then don't touch the item. Assume it got deleted */
@ -452,9 +453,11 @@ static int ebSegExpire(FirstSegHdr *firstSegHdr,
if (act == ACT_UPDATE_EXP_ITEM) {
mIter->next = *updateList;
*updateList = toDelete;
*updateList = iter;
}
/* Item was REMOVED/UPDATED. Advance to `next` item */
iter = next;
++info->itemsExpired;
firstSegHdr->totalItems -= 1;
}
@ -672,6 +675,7 @@ static int ebListExpire(ebuckets *eb,
if (info->itemsExpired == info->maxToExpire)
break;
/* keep aside `next` before removing `iter` by onExpireItem */
eItem *next = metaItem->next;
metaItem->trash = 1;
ExpireAction act = info->onExpireItem(item, info->ctx);