Activities running in different workers even with session enabled

TLDR
I have 2 workflows, 1 parent and 1 child. I want parent and its activities to run in one worker, while child and its activities to run in another worker. I tried to use session but it didn’t work.

Did you check the file processing example?
Yes

How do you use session in parent workflow?

childWorkflowOpts := workflow.ChildWorkflowOptions{
ParentClosePolicy: enums.PARENT_CLOSE_POLICY_REQUEST_CANCEL,
}
ctx = workflow.WithChildOptions(ctx, childWorkflowOpts)
wctx := createDefaultContext(ctx)

// Create workflow session
so := &workflow.SessionOptions{
CreationTimeout: time.Minute,
ExecutionTimeout: monthTime,
}
wctx, err := workflow.CreateSession(wctx, so)
if err != nil {
logWorkflowError(wctx, “Failed to create workflow session”, err)
return nil, err
}

// execute activity
err = workflow.ExecuteActivity(wctx, e.createWorkspaceParent, workspaceParent).Get(wctx, nil)
if err != nil {

}

How do you spawn the child workflow?

futures = append(futures, workflow.ExecuteChildWorkflow(
wctx, // same context as above
…))
err = futures[i].GetChildWorkflowExecution().Get(wctx, nil)

How do you use session in child workflow?

wctx := createDefaultContext(ctx)

// Create workflow session
so := &workflow.SessionOptions{
CreationTimeout: time.Minute,
ExecutionTimeout: monthTime,
}
wctx, err := workflow.CreateSession(wctx, so)
if err != nil {

}

// execute activity
err = workflow.ExecuteActivity(wctx, e.activities[0].Name, workspaceChild).Get(wctx, nil)
if err != nil {

}

Did you set EnableSessionWorker to true in worker options?
Yes

How do you know the activities are running in different workers?
I inspected the logs for both workers. I could see they were executing activities from both workflows.

Are those 2 workers listening to the same task queue?
Yes

Can someone please suggest what might be the cause here?

Thanks,
Shi

A quick update, I printed out the session info with workflow.GetSessionInfo function. The weird thing is parent and child workflows share the same session host, even they sessions are created in different workers. Does anyone see this before?

Activities for a session can work only within the workflow and you cannot pass the session to a child workflow. Is this what you are expecting to happen here (provide more info pls).

Also do you execute more than one activity in each of the workflows? If you invoke just single I’m not sure sessions would be needed for the user case.

Raised issue here, just fyi.