Fix incorrect Dispatcher state clear on incremental invalidation
Some constraints could be missed: those which are activated and discarded in the same Chunk. Dispatcher weren't cleared from them and stale matches could remain in its state. Through these matches their invalidated heads could get into incremental execution queue which led to assert violation in MatchJournalImpl.reset
This commit is contained in:
parent
ad9f02dd7d
commit
693cfbb15d
|
|
@ -96,7 +96,7 @@ internal class ConstraintsProcessing(private var dispatchingFront: Dispatcher.Di
|
|||
// Remove chunk from the journal
|
||||
it.remove()
|
||||
// 'Undo' all activated in this chunk occurrences
|
||||
chunk.activated().forEach {
|
||||
chunk.activatedLog().forEach {
|
||||
dispatchingFront = dispatchingFront.forget(it)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ internal class ExecutionQueue(
|
|||
|
||||
// If the occurrence is still in the store after replay (i.e. if it's valid to activate it)
|
||||
if (execPos.activeOcc.stored) {
|
||||
// fixme: parentChunk can also be tracked
|
||||
status = processing.activateContinue(controller, execPos.activeOcc, processing.parentChunk())
|
||||
// Leave journal processing as it was at the point of failure
|
||||
if (!status.operational) return status
|
||||
|
|
@ -107,12 +106,13 @@ internal class ExecutionQueue(
|
|||
|
||||
// if it is a future match
|
||||
if (pos != null && journalIndex.compare(lastIncrementalRootPos, pos) < 0) {
|
||||
// TODO: Remove extra logic with 'postponedMatches'
|
||||
// when following Dispatcher contract is specified/checked:
|
||||
// Dispatcher returns unconsumed matches relevant for offered
|
||||
// activation on future calls to Dispatcher.matches().
|
||||
// With this there's no need to store them here.
|
||||
// val idOcc = Id(occChunk.occ)
|
||||
// postponedMatches[idOcc] = (postponedMatches[idOcc] ?: emptyList()) + listOf(m)
|
||||
// TODO: Seems, Dispatcher will again return these unconsumed
|
||||
// future matches on this offered activation,
|
||||
// so there's no need to store them.
|
||||
// Remove extra logic with 'postponedMatches'.
|
||||
offer(pos, occChunk)
|
||||
} else {
|
||||
currentMatches.add(m)
|
||||
|
|
|
|||
|
|
@ -176,12 +176,6 @@ interface MatchJournal : MutableIterable<MatchJournal.Chunk>, EvidenceSource {
|
|||
*/
|
||||
fun discardedLog(): List<Occurrence> = entries().filter { it.discarded }.map { it.occ }
|
||||
|
||||
/**
|
||||
* Returns the resulting collection of activated occurrences
|
||||
* without discarded (only in this chunk!) occurrences.
|
||||
*/
|
||||
fun activated(): List<Occurrence> = entries().allOccurrences()
|
||||
|
||||
fun toPos(): Pos = Pos(this, entries().size)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue