@@ -14,7 +14,6 @@ import (
1414 "github.com/temporalio/omes/loadgen"
1515 . "github.com/temporalio/omes/loadgen/kitchensink"
1616 "go.temporal.io/api/common/v1"
17- "go.temporal.io/api/serviceerror"
1817 "go.temporal.io/api/workflowservice/v1"
1918 "go.temporal.io/sdk/temporal"
2019 "google.golang.org/protobuf/types/known/emptypb"
@@ -201,19 +200,6 @@ func (t *tpsExecutor) Run(ctx context.Context, info loadgen.ScenarioInfo) error
201200 info .Logger .Debugf ("Completed iteration %d" , run .Iteration )
202201 }
203202
204- // When resuming, it can happen that the workflow for the current iteration already exists since the snapshot
205- // was not up-to-date. In that case, we just skip this iteration and move on.
206- info .Configuration .HandleExecuteError = func (ctx context.Context , run * loadgen.Run , err error ) error {
207- if isResuming {
208- var alreadyStartedErr * serviceerror.WorkflowExecutionAlreadyStarted
209- if errors .As (err , & alreadyStartedErr ) {
210- info .Logger .Warnf ("after resume, workflow for iteration %d already exists" , run .Iteration )
211- return nil
212- }
213- }
214- return err
215- }
216-
217203 // Start the scenario run.
218204 //
219205 // NOTE: When resuming, it can happen that there are no more iterations/time left to run more iterations.
@@ -228,7 +214,11 @@ func (t *tpsExecutor) Run(ctx context.Context, info loadgen.ScenarioInfo) error
228214 },
229215 },
230216 UpdateWorkflowOptions : func (ctx context.Context , run * loadgen.Run , options * loadgen.KitchenSinkWorkflowOptions ) error {
231- options .StartOptions .ID = workflowID (run .RunID , run .Iteration )
217+ options .StartOptions = run .DefaultStartWorkflowOptions ()
218+ if isResuming {
219+ // Enforce to never fail on "workflow already started" when resuming.
220+ options .StartOptions .WorkflowExecutionErrorWhenAlreadyStarted = false
221+ }
232222
233223 // Add search attribute to the workflow options so that it can be used in visibility queries.
234224 options .StartOptions .TypedSearchAttributes = temporal .NewSearchAttributes (
@@ -255,7 +245,7 @@ func (t *tpsExecutor) Run(ctx context.Context, info loadgen.ScenarioInfo) error
255245 //
256246 // NOTE: No client actions (e.g. Signal) are defined; however, client action activities are.
257247 // That means these client actions are sent from the activity worker instead of Omes.
258- options .Params .WorkflowInput .InitialActions = t .createActions (run . Iteration )
248+ options .Params .WorkflowInput .InitialActions = t .createActions (run )
259249
260250 return nil
261251 },
@@ -343,17 +333,17 @@ func (t *tpsExecutor) updateStateOnIterationCompletion() {
343333 t .state .LastCompletedIterationAt = time .Now ()
344334}
345335
346- func (t * tpsExecutor ) createActions (iteration int ) []* ActionSet {
336+ func (t * tpsExecutor ) createActions (run * loadgen. Run ) []* ActionSet {
347337 return []* ActionSet {
348338 {
349- Actions : t .createActionsChunk (iteration , 0 , 0 , t .config .InternalIterations ),
339+ Actions : t .createActionsChunk (run , 0 , 0 , t .config .InternalIterations ),
350340 Concurrent : false ,
351341 },
352342 }
353343}
354344
355345func (t * tpsExecutor ) createActionsChunk (
356- iteration int ,
346+ run * loadgen. Run ,
357347 childCount int ,
358348 continueAsNewCounter int ,
359349 remainingInternalIters int ,
@@ -367,7 +357,7 @@ func (t *tpsExecutor) createActionsChunk(
367357 isLastChunk := remainingInternalIters <= itersPerChunk
368358 itersPerChunk = min (itersPerChunk , remainingInternalIters ) // cap chunk size to remaining iterations
369359
370- rng := rand .New (rand .NewSource (t .config .RngSeed + int64 (iteration )))
360+ rng := rand .New (rand .NewSource (t .config .RngSeed + int64 (run . Iteration )))
371361
372362 // Create actions for the current chunk
373363 for i := 0 ; i < itersPerChunk ; i ++ {
@@ -381,7 +371,7 @@ func (t *tpsExecutor) createActionsChunk(
381371
382372 childCount ++
383373 asyncActions := []* Action {
384- t .createChildWorkflowAction (iteration , childCount ),
374+ t .createChildWorkflowAction (run , childCount ),
385375 PayloadActivity (256 , 256 , DefaultRemoteActivity ),
386376 PayloadActivity (256 , 256 , DefaultRemoteActivity ),
387377 PayloadActivity (0 , 256 , DefaultLocalActivity ),
@@ -445,7 +435,7 @@ func (t *tpsExecutor) createActionsChunk(
445435 InitialActions : []* ActionSet {
446436 {
447437 Actions : t .createActionsChunk (
448- iteration ,
438+ run ,
449439 childCount ,
450440 continueAsNewCounter + 1 ,
451441 remainingInternalIters - itersPerChunk ),
@@ -462,7 +452,7 @@ func (t *tpsExecutor) createActionsChunk(
462452 return chunkActions
463453}
464454
465- func (t * tpsExecutor ) createChildWorkflowAction (iteration int , childID int ) * Action {
455+ func (t * tpsExecutor ) createChildWorkflowAction (run * loadgen. Run , childID int ) * Action {
466456 return & Action {
467457 Variant : & Action_ExecChildWorkflow {
468458 ExecChildWorkflow : & ExecuteChildWorkflowAction {
@@ -481,7 +471,7 @@ func (t *tpsExecutor) createChildWorkflowAction(iteration int, childID int) *Act
481471 },
482472 }),
483473 },
484- WorkflowId : fmt .Sprintf ("%s/child-%d" , workflowID ( t . runID , iteration ) , childID ),
474+ WorkflowId : fmt .Sprintf ("%s/child-%d" , run . DefaultStartWorkflowOptions (). ID , childID ),
485475 SearchAttributes : map [string ]* common.Payload {
486476 ThroughputStressScenarioIdSearchAttribute : & common.Payload {
487477 Metadata : map [string ][]byte {"encoding" : []byte ("json/plain" )},
@@ -623,10 +613,6 @@ func (t *tpsExecutor) createNexusWaitForCancelAction() *Action {
623613 }
624614}
625615
626- func workflowID (runID string , iteration int ) string {
627- return fmt .Sprintf ("throughputStress/%s/iter-%d" , runID , iteration )
628- }
629-
630616func (t * tpsExecutor ) maybeWithStart (likelihood float64 ) bool {
631617 t .lock .Lock ()
632618 defer t .lock .Unlock ()
0 commit comments