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

Add more logging message to monitor branch token update #5058

Merged
merged 6 commits into from
Oct 31, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions service/history/api/get_workflow_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"go.temporal.io/server/api/historyservice/v1"
"go.temporal.io/server/common"
"go.temporal.io/server/common/definition"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/persistence/versionhistory"
serviceerrors "go.temporal.io/server/common/serviceerror"
Expand All @@ -53,6 +54,7 @@ func GetOrPollMutableState(
eventNotifier events.Notifier,
) (*historyservice.GetMutableStateResponse, error) {

logger := shardContext.GetLogger()
namespaceID := namespace.ID(request.GetNamespaceId())
err := ValidateNamespaceUUID(namespaceID)
if err != nil {
Expand Down Expand Up @@ -94,6 +96,14 @@ func GetOrPollMutableState(
// We return the full version histories. Callers need to fetch the last version history item from current branch
// and use the last version history item in following calls.
if !versionhistory.ContainsVersionHistoryItem(currentVersionHistory, request.VersionHistoryItem) {
logItem, err := versionhistory.GetLastVersionHistoryItem(currentVersionHistory)
if err != nil {
return nil, err
}
logger.Warn("Request history branch and current history branch don't match",
tag.Value(logItem),
tag.TokenLastEventVersion(request.VersionHistoryItem.GetVersion()),
tag.TokenLastEventID(request.VersionHistoryItem.GetEventId()))
return nil, serviceerrors.NewCurrentBranchChanged(response.CurrentBranchToken, request.CurrentBranchToken)
}

Expand Down Expand Up @@ -121,6 +131,14 @@ func GetOrPollMutableState(
return nil, err
}
if !versionhistory.ContainsVersionHistoryItem(currentVersionHistory, request.VersionHistoryItem) {
logItem, err := versionhistory.GetLastVersionHistoryItem(currentVersionHistory)
if err != nil {
return nil, err
}
logger.Warn("Request history branch and current history branch don't mismatch prior to poll the mutable state.",
yux0 marked this conversation as resolved.
Show resolved Hide resolved
tag.Value(logItem),
tag.TokenLastEventVersion(request.VersionHistoryItem.GetVersion()),
tag.TokenLastEventID(request.VersionHistoryItem.GetEventId()))
return nil, serviceerrors.NewCurrentBranchChanged(response.CurrentBranchToken, request.CurrentBranchToken)
}
if expectedNextEventID < response.GetNextEventId() || response.GetWorkflowStatus() != enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING {
Expand Down Expand Up @@ -152,6 +170,14 @@ func GetOrPollMutableState(
response.CurrentBranchToken = latestVersionHistory.GetBranchToken()
response.VersionHistories = event.VersionHistories
if !versionhistory.ContainsVersionHistoryItem(latestVersionHistory, request.VersionHistoryItem) {
logItem, err := versionhistory.GetLastVersionHistoryItem(currentVersionHistory)
if err != nil {
return nil, err
}
logger.Warn("Request history branch and current history branch don't match after polling the mutable state",
tag.Value(logItem),
tag.TokenLastEventVersion(request.VersionHistoryItem.GetVersion()),
tag.TokenLastEventID(request.VersionHistoryItem.GetEventId()))
return nil, serviceerrors.NewCurrentBranchChanged(response.CurrentBranchToken, request.CurrentBranchToken)
}
if expectedNextEventID < response.GetNextEventId() || response.GetWorkflowStatus() != enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING {
Expand Down
Loading