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

Update replication use branch token #3447

Merged
merged 5 commits into from Oct 6, 2022

Conversation

yux0
Copy link
Contributor

@yux0 yux0 commented Sep 30, 2022

What changed?

Why?

How did you test it?

Potential risks

Is hotfix candidate?

@yux0 yux0 requested a review from wxing1292 September 30, 2022 04:37
taskInfo.FirstEventID,
taskInfo.NextEventID,
)
if err != nil {
return nil, err
}

var newRunBranchToken []byte
if len(taskInfo.NewRunID) > 0 {
newRunContext, releaseFn, err := p.workflowCache.GetOrCreateWorkflowExecution(
Copy link
Contributor

Choose a reason for hiding this comment

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

if new run ID is set, then here is taking another lock.
can we modify the logic to lock & get the branch token one by one, instead of double lock & double unlock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see the concern here. Updated to not have the overlap.

Comment on lines 727 to 732
newRunBranchToken := newRunTask.BranchToken
newRunID := newRunTask.RunID
taskUpdated := false
for _, replicationTask := range currentWorkflowMutation.Tasks[tasks.CategoryReplication] {
if task, ok := replicationTask.(*tasks.HistoryReplicationTask); ok {
taskUpdated = true
task.NewRunBranchToken = newRunBranchToken
task.NewRunID = newRunID
Copy link
Contributor

Choose a reason for hiding this comment

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

to support forward / backward compatibility, branch token & run ID should both be set?
task processing logic should use run ID if run ID is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Keep both for compatibility

@yux0 yux0 marked this pull request as ready for review September 30, 2022 17:47
@yux0 yux0 requested a review from a team as a code owner September 30, 2022 17:47
taskVersion,
)
if err != nil {
releaseFn(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

if the intention is to reduce locking, then maybe create a function just for getting the branch token? then reuse this function for normal runs & continue as new runs

@yux0 yux0 merged commit 0df719d into temporalio:master Oct 6, 2022
@yux0 yux0 deleted the replication-branch-token branch October 6, 2022 21:34
dnr pushed a commit that referenced this pull request Oct 10, 2022
* Update replication use branch token
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.

None yet

3 participants