feat: recover poll activations within original round budgets

This commit is contained in:
2026-09-18 05:40:08 +08:00
parent 1d1a441167
commit 56b9a2ccfe
32 changed files with 1051 additions and 65 deletions

View File

@@ -16,8 +16,7 @@ import (
"git.yuntuo.hk/k2safe/orbit/weave/recovery"
)
// RetryStep 为TASK建立新的执行激活;保留旧激活、原输入和绝对截止,跨激活扣除已用尝试。
// POLL恢复需要同时保留原轮次身份,不在此处降级成新查询轮次。
// RetryStep 为TASK或POLL建立新的执行激活;保留原输入、绝对截止和跨激活尝试预算。
func (s *WorkflowRecoveryStore) RetryStep(ctx context.Context, t auth.Token, id core.ID, key string, in recovery.RetryStepInput) (recovery.Result, error) {
return s.mutate(ctx, t, id, key, "workflow.step.retry", in, in.Decision, func(tx *sql.Tx, g *workflowGraph, _ core.ID, now time.Time, out *recovery.Result) (map[string]any, error) {
row, err := workflowRecoveryStep(g, in.StepDecision)
@@ -28,12 +27,15 @@ func (s *WorkflowRecoveryStore) RetryStep(ctx context.Context, t auth.Token, id
return nil, fault.Conflict
}
node, ok := g.program.Step(row.view.Key)
if !ok || node.Task == nil {
return nil, fault.Invalid("this retry operation currently supports TASK steps only")
if !ok || node.Task == nil && node.Poll == nil {
return nil, fault.Invalid("retry currently supports TASK and POLL steps")
}
if err := workflowStepSettled(ctx, tx, g, row); err != nil {
return nil, err
}
if node.Poll != nil {
return retryWorkflowPoll(ctx, tx, g, row, in, now, out)
}
var sequence uint32
if err := tx.QueryRowContext(ctx, `SELECT sequence FROM weave_activations WHERE namespace_id=? AND id=?`, t.NamespaceID, row.view.ActivationID).Scan(&sequence); err != nil {
return nil, err