Rename RestartExecution/s to ClaimFunction/s and add owner-guarded SetFunction#190
Open
stidsborg wants to merge 1 commit into
Open
Rename RestartExecution/s to ClaimFunction/s and add owner-guarded SetFunction#190stidsborg wants to merge 1 commit into
stidsborg wants to merge 1 commit into
Conversation
1417785 to
dcb8af0
Compare
…tFunction The store's RestartExecution/RestartExecutions really take over ownership of a flow and hand back its current state, so rename them to ClaimFunction/ClaimFunctions across the IFunctionStore interface, all four stores and their SqlGenerators, the test doubles and the store test templates. The higher-level FlowsManager.RestartExecutions(messages) orchestration, InvocationHelper.RestartFunction and the RestartedFunction record keep their names; only their store calls are repointed. Add IFunctionStore.SetFunction: an owner-guarded general state-setter that writes status, owner (null releases) and, when provided, the effects snapshot in a single UPDATE guarded by owner = expectedReplica. expectedReplica is non-nullable - the caller must already own the flow - matching the terminal writers. Its final IStorageSession? parameter is the store's forward-carried per-flow context (typically handed back by ClaimFunction); when supplied it is kept coherent with the persisted effect snapshot, mirroring each store's EffectsStore.SetEffectResults bookkeeping. Together with ClaimFunction this gives a claim-commit-release primitive without bespoke SQL. Surface the flow's current result bytes on the claim result by adding Result to StoredFlowWithEffects (StorageSession kept last), populated from result_json (SQL stores) and the in-memory state, so a caller can pass it straight into SetFunction without nulling the result. Build clean; InMemory 521 passed; ClaimFunction/SetFunction green on Postgres/SqlServer/MariaDB; full PostgreSQL suite 373 passed.
dcb8af0 to
4bcea88
Compare
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.
What & why
Groundwork that renames the store-level "restart" primitives to what they actually do — claim (take over ownership of a flow and return its current state) — and adds an owner-guarded state-setter. This unblocks a follow-up simplification of
TryInlinePendingMessages(inlining a completed flow's late messages), which becomes:ClaimFunction→ merge messages into the effect snapshot →SetFunction(status, owner: null, effects: merged, result: claimed.Result, expectedReplica: self, storageSession: claimed.StorageSession)→ clear rows — a single owner-guarded write with no merge-write-verify retry loop.Changes
IFunctionStore.RestartExecution → ClaimFunction,RestartExecutions → ClaimFunctionsacross the interface, all four stores + theirSqlGenerators, test doubles, call sites (incl.PostponedWatchdog) and store test templates.FlowsManager.RestartExecutions(IEnumerable<StoredMessages>)(message-delivery orchestration),InvocationHelper.RestartFunction, and theRestartedFunctionrecord.IFunctionStore.SetFunction— an owner-guarded general state-setter:owner = expectedReplica; returnstrueiff the guard matched.expectedReplicais non-nullable — a caller must own the flow to use it (matchingSucceed/Fail). The finalstorageSessionis the store's opaque per-flow context; when supplied it's kept coherent with the persisted effect snapshot, mirroring each store'sEffectsStore.SetEffectResultsbookkeeping (InMemory advancesVersion/RowExists/Effects; the SQL stores updateEffects/RowExistsunder owner-based concurrency).ResulttoStoredFlowWithEffects(StorageSessionkept last), populated fromresult_json(SQL stores) / in-memory state, so a claimer can feed the flow's current result intoSetFunctionwithout nulling it.Validation
dotnet build— 0 errors, 0 warnings.ClaimFunction+SetFunction— 18 passed each on InMemory / Postgres / SqlServer / MariaDB (incl. a session-threading test asserting the session stays coherent afterSetFunction).No behavior change to existing flows — pure rename + additive owner-guarded primitive + additive
Resultfield.🤖 Generated with Claude Code