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

Fix task state change for state based replication #6816

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xwduan
Copy link
Contributor

@xwduan xwduan commented Nov 14, 2024

What changed?

Add new api for updating timer task status

Why?

We need to distinguish the user data update and timer task status update because we don't need to update state transition when the change is task status update change.

How did you test it?

unit test

Potential risks

n/a

Documentation

n/a

Is hotfix candidate?

no

@xwduan xwduan marked this pull request as ready for review November 15, 2024 00:37
@xwduan xwduan requested a review from a team as a code owner November 15, 2024 00:37
ms.approximateSize += ai.Size() - prev.Size()
return nil
}
func (ms *MutableStateImpl) UpdateActivityTimerTaskStatus(
Copy link
Member

Choose a reason for hiding this comment

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

nit: let's add some comment on UpdateActivity() saying it ideally should not be used and if used, can only be used when user data needs to be changed. Same for UpdateUserTimer()

ai.TimerTaskStatus = status
ms.updateActivityInfos[ai.ScheduledEventId] = ai
return nil
}

// UpdateActivityWithTimerHeartbeat updates an activity
func (ms *MutableStateImpl) UpdateActivityWithTimerHeartbeat(
Copy link
Member

Choose a reason for hiding this comment

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

this method needs to call UpdateActivityTimerTaskStatus as well.

Comment on lines +209 to +210
updateActivityInfosUserDataUpdated map[int64]struct{}
updateTimerInfosUserDataUpdated map[string]struct{}
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
updateActivityInfosUserDataUpdated map[int64]struct{}
updateTimerInfosUserDataUpdated map[string]struct{}
activityInfosUserDataUpdated map[int64]struct{}
timerInfosUserDataUpdated map[string]struct{}

Copy link
Member

Choose a reason for hiding this comment

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

Plz also add some comment explaining why we need this in addition to updateActivityInfos and updateTimerInfos

refreshUserTimerTask = true

// need to update user timer task mask for which task is generated
if err := mutableState.UpdateUserTimer(
timerInfo,
if err := mutableState.UpdateUserTimerTaskStatus(
Copy link
Member

Choose a reason for hiding this comment

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

I believe we have the same logic in this file for clearing activity timer task status, that needs to be updated as well.

@@ -450,12 +450,12 @@ func (r *TaskRefresherImpl) refreshTasksForTimer(
}

// clear timer task mask for later timer task re-generation
Copy link
Member

Choose a reason for hiding this comment

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

nit: move the comment as well.

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