Fail Suspend/Postpone when function is currently interrupted#149
Closed
stidsborg wants to merge 3 commits into
Closed
Fail Suspend/Postpone when function is currently interrupted#149stidsborg wants to merge 3 commits into
stidsborg wants to merge 3 commits into
Conversation
Previously, SuspendFunction and PostponeFunction silently absorbed the interrupted flag at the storage layer: they converted the requested state into Postponed(expires=0) and cleared the flag, returning true. The runtime never saw that an interrupt had been observed. Now both methods return false when the row has interrupted=true, letting the caller treat the interrupt as a real signal: - SuspendFunction: gains AND interrupted = FALSE in its WHERE clause - PostponeFunction: same, but gated on a new failIfInterrupted=true default param so InvocationHelper.Reschedule can still pass false to consume the interrupt and queue the function for immediate re-pickup - InvocationHelper.PersistResult Postpone case now returns Reschedule on false (was: Success on both branches, swallowing failure) Replaces 4 obsolete tests that pinned the old silent-convert behaviour with 3 new tests covering the new contract across all 4 stores.
Parameter is no longer optional with a default; every caller picks the behaviour explicitly. Updated all 4 store implementations, both CrashableFunctionStore wrappers, InvocationHelper's two call sites (true for user-yield, false for Reschedule), and the remaining test call sites which now pass failIfInterrupted: true to match the prior default semantics.
Replace the if/failIfInterrupted/else branching with a single cached SQL per shape (with/without effects), gated by a runtime parameter: WHERE ... AND (@FailIfInterrupted = 0 OR Interrupted = 0) The SET clause unconditionally clears interrupted, which is a no-op when WHERE already requires it false and the intended consumption otherwise. Halves the SQL caches in PG, MariaDB, and SqlServer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Previously,
SuspendFunctionandPostponeFunctionsilently absorbed the interrupted flag at the storage layer — they converted the requested state intoPostponed(expires=0)and cleared the flag, returningtrue. The runtime never saw that an interrupt had been observed, so an interrupt arriving mid-execution was effectively invisible to the caller.Now both methods return
falsewhen the row is currently interrupted, letting the caller treat the interrupt as a real signal.Changes
SuspendFunction: SQL/WHERE now gated oninterrupted = FALSE; returns false if the row is interrupted. Status staysExecuting, flag stays set.PostponeFunction: same guard, but gated on a newfailIfInterrupted: bool = trueparameter so the runtime's internalReschedulepath can opt out (failIfInterrupted: false) and queue the function for immediate re-pickup while consuming the interrupt.InvocationHelper.PersistResultPostpone case now returnsRescheduleon false (was:Successon both branches, which swallowed the failure).InvocationHelper.ReschedulepassesfailIfInterrupted: falsesince it's the consumer of the interrupt signal.Applied uniformly across InMemory, PostgreSQL, MariaDB, and SqlServer stores.
Tests
Replaced 4 obsolete tests that pinned the old silent-convert behaviour with 3 new contract tests, wired into all 4 stores:
SuspendingInterruptedFunctionReturnsFalsePostponingInterruptedFunctionReturnsFalsePostponingInterruptedFunctionWithFailIfInterruptedFalseSucceedsAndClearsFlagTest plan