Hi,
I’ve been recently trying to build a workflow to create users in bulk. Mainly because this process is long and it wasn’t very resilient. This process has a few steps, let’s call them step A
,B
& C
.
So, for each step, I call a child workflow and run the activities in parallel (in blocks of 200 activities). Something like so:
[Inside Workflow]
ctx = workflow.WithChildOptions(ctx, chOptions)
// companyID int64 - fileID UUID - owner string
future := workflow.ExecuteChildWorkflow(ctx, Step, companyID, fileID, owner)
err := future.Get(ctx, nil)
if err != nil {
return errors.Wrap(err, "failed to run child workflow")
}
[Inside the child workflow]
actOptions := workflow.ActivityOptions{
StartToCloseTimeout: 10 * time.Minute,
}
ctx = workflow.WithActivityOptions(ctx, actOptions)
// groupSize = 200
userGroupInstructions := userInstructions.SplitInGroups(groupSize)
for _, instructions := range userGroupInstructions {
var futures []workflow.Future
for _, processInstruction := range instructions {
fut := workflow.ExecuteActivity(ctx, ActivityA, instructionID)
futures = append(futures, fut)
}
for _, future := range futures {
err := future.Get(ctx, nil)
if err != nil {
fmt.Printf("failed to execute activity: %v\n", err.Error())
}
}
}
This is the plan I currently have implemented.
I apologize in advance if it’s silly, I’m fairly new to this and I’m trying to make it work in the best way possible.
That’s why I’m seeking your advice on this, especially because after the workflow has been running for a while, I start seeing the lookup failed for scheduledEventID to activityID
(followed by a panic) error, and some activities are closed with the error WORKFLOW_TASK_FAILED_CAUSE_FORCE_CLOSE_COMMAND
.
Any advice is well appreciated, thank you in advance to anyone who read through this.