Skip to content

Commit 8d8aabb

Browse files
committed
Prevent us from starting a rehash when one wasn't already in progress. This can cause severe issues for snapshots
1 parent 418356c commit 8d8aabb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/dict.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,18 @@ bool dictRehashSomeAsync(dictAsyncRehashCtl *ctl, size_t hashes) {
468468

469469

470470
void discontinueAsyncRehash(dict *d) {
471+
// We inform our async rehashers and the completion function the results are to be
472+
// abandoned. We keep the asyncdata linked in so that dictEntry's are still added
473+
// to the GC list. This is because we can't gurantee when the other threads will
474+
// stop looking at them.
471475
if (d->asyncdata != nullptr) {
472476
auto adata = d->asyncdata;
473-
while (adata != nullptr) {
477+
while (adata != nullptr && !adata->abondon.load(std::memory_order_relaxed)) {
474478
adata->abondon = true;
475479
adata = adata->next;
476480
}
477-
d->rehashidx = 0;
481+
if (dictIsRehashing(d))
482+
d->rehashidx = 0;
478483
}
479484
}
480485

0 commit comments

Comments
 (0)