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

use transition history if enabled when long poll history #7185

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

Conversation

hai719
Copy link
Contributor

@hai719 hai719 commented Jan 30, 2025

What changed?

use transition history if enabled when long poll history

Why?

For state-based replication, we do allow event version version to go backwards as long as the overall versioned transition is keep increasing. So we need to change token to use versioned transition.

How did you test it?

unit test.

Potential risks

Documentation

Is hotfix candidate?

@hai719 hai719 marked this pull request as ready for review January 30, 2025 18:00
@hai719 hai719 requested a review from a team as a code owner January 30, 2025 18:00
Comment on lines +320 to +324
if len(transitionHistory) != 0 {
if versionedTransition != nil && workflow.TransitionHistoryStalenessCheck(transitionHistory, versionedTransition) != nil {
return false
}
return true
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
if len(transitionHistory) != 0 {
if versionedTransition != nil && workflow.TransitionHistoryStalenessCheck(transitionHistory, versionedTransition) != nil {
return false
}
return true
if len(transitionHistory) != 0 && versionedTransition != nil {
return workflow.TransitionHistoryStalenessCheck(transitionHistory, versionedTransition) == nil
}

transitionHistory := response.GetTransitionHistory()
if len(transitionHistory) != 0 {
if request.VersionedTransition != nil && workflow.TransitionHistoryStalenessCheck(transitionHistory, request.VersionedTransition) != nil {
logger.Warn(fmt.Sprintf("Request versioned transition and transition history prior to polling the mutable state. Request: %v, current: %v",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logger.Warn(fmt.Sprintf("Request versioned transition and transition history prior to polling the mutable state. Request: %v, current: %v",
logger.Warn(fmt.Sprintf("Request versioned transition and transition history don't match prior to polling the mutable state. Request: %v, current: %v",

tag.WorkflowRunID(workflowKey.GetRunID()))
return nil, serviceerrors.NewCurrentBranchChanged(response.CurrentBranchToken, request.CurrentBranchToken)
}
} else if !versionhistory.ContainsVersionHistoryItem(currentVersionHistory, request.VersionHistoryItem) {
Copy link
Member

Choose a reason for hiding this comment

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

hmm shall we fallback to version history check when either transitionHistory or request.VersionedTransition is empty?
Looks right now, if transitionHistory is no empty but request.VersionedTransition is empty, we will just skip the validation priori to polling mutable state.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have the same question on if this is a valid case on transitionHistory is no empty but request.VersionedTransition is empty

Copy link
Member

Choose a reason for hiding this comment

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

it will happen when we start to rollout state based replication so we have to handle it. I think we can just validate version history in that case.

tag.WorkflowRunID(workflowKey.GetRunID()))
return nil, serviceerrors.NewCurrentBranchChanged(response.CurrentBranchToken, request.CurrentBranchToken)
}
} else if !versionhistory.ContainsVersionHistoryItem(eventVersionHistory, request.VersionHistoryItem) {
Copy link
Member

Choose a reason for hiding this comment

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

Same Q here.

service/history/events/notifier.go Show resolved Hide resolved
Comment on lines +110 to +114
var lastVersionedTransition *persistencespb.VersionedTransition
transitionHistory := response.GetTransitionHistory()
if transitionHistory != nil {
lastVersionedTransition = transitionHistory[len(transitionHistory)-1]
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: make this a util function as well for getting the last versioned transition? I think I have seen this logic in couple of places.

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.

3 participants