Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler Component: reduce executeScheduleRunTask's read critical section #6569

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lina-temporal
Copy link
Contributor

What changed?

  • Reduced the scope of the env.Access read critical section in the new scheduler's run task.

Why?

How did you test it?

  • make unit-test

Potential risks

  • bug in scheduler component

Documentation

no

Is hotfix candidate?

no

@lina-temporal lina-temporal requested a review from a team as a code owner September 26, 2024 23:29
Comment on lines +181 to +191
// Ensure that this is copy, so later (stateful) processing does not update state machine without protection
s = Scheduler{
HsmSchedulerState: common.CloneProto(prevS.HsmSchedulerState),
cspec: prevS.cspec,
}

// Copy the list of current running workflows so we can tell later which ones are newly started
prevRunningWorkflows = make([]*commonpb.WorkflowExecution, len(prevS.Args.Info.RunningWorkflows))
for i := 0; i < len(prevS.Args.Info.RunningWorkflows); i++ {
prevRunningWorkflows[i] = prevS.Args.Info.RunningWorkflows[i]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should clone while holding the lock otherwise the struct may be mutated concurrently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants