Prevent us from starting a rehash when one wasn't already in progress. This can cause severe issues for snapshots

This commit is contained in:
John Sully 2022-05-17 02:59:32 +00:00
parent 418356c03a
commit 8d8aabb978

View File

@ -468,13 +468,18 @@ bool dictRehashSomeAsync(dictAsyncRehashCtl *ctl, size_t hashes) {
void discontinueAsyncRehash(dict *d) {
// We inform our async rehashers and the completion function the results are to be
// abandoned. We keep the asyncdata linked in so that dictEntry's are still added
// to the GC list. This is because we can't gurantee when the other threads will
// stop looking at them.
if (d->asyncdata != nullptr) {
auto adata = d->asyncdata;
while (adata != nullptr) {
while (adata != nullptr && !adata->abondon.load(std::memory_order_relaxed)) {
adata->abondon = true;
adata = adata->next;
}
d->rehashidx = 0;
if (dictIsRehashing(d))
d->rehashidx = 0;
}
}