Skip to content

Commit dedae9b

Browse files
committed
Fix deadlock avoidance once again
If we requeue ks, then we can no longer continue iterating against the original list. Let's have a separate ksIter. We only progress it to the next key in case no requeueing takes place.
1 parent 8fee1e2 commit dedae9b

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

pkg/model/evaluation/recursive_computer.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,17 @@ func (rc *RecursiveComputer[TReference, TMetadata]) ProcessNextEvaluatableKey(ct
177177

178178
blockedCyclic := make(map[*KeyState[TReference, TMetadata]]bool, rc.blockedKeys.count)
179179
disabledCacheLookupOnAKey := false
180-
for ks := &rc.blockedKeys.head.nextKey; *ks != &rc.blockedKeys.head; ks = &(*ks).nextKey {
181-
if (*ks).isBlockedCyclic(blockedOn, blockedCyclic) {
182-
if newValueState := (*ks).valueState.disableCacheLookup(); newValueState != nil {
183-
(*ks).valueState = newValueState
184-
rc.forceUnblockKeyState(*ks, blockedOn[*ks])
185-
rc.enqueueForEvaluation(*ks)
180+
for ksIter := &rc.blockedKeys.head.nextKey; *ksIter != &rc.blockedKeys.head; {
181+
if ks := *ksIter; ks.isBlockedCyclic(blockedOn, blockedCyclic) {
182+
if newValueState := ks.valueState.disableCacheLookup(); newValueState != nil {
183+
ks.valueState = newValueState
184+
rc.forceUnblockKeyState(ks, blockedOn[ks])
185+
rc.enqueueForEvaluation(ks)
186186
disabledCacheLookupOnAKey = true
187+
continue
187188
}
188189
}
190+
ksIter = &(*ksIter).nextKey
189191
}
190192

191193
if !disabledCacheLookupOnAKey {

0 commit comments

Comments
 (0)