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

Don't replay commands from non-completed task #1750

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

Conversation

yuandrew
Copy link
Contributor

@yuandrew yuandrew commented Dec 9, 2024

What was changed

Skip any commands that aren't a part of a completed WFT (a.k.a. if WFT start is the last event)

Why?

Fix issue where we're hitting NDE when we shouldn't be.

Checklist

  1. Closes Erroneous extra replay command when replaying mid-workflow tasks #1670

  2. How was this tested:

Added new test

  1. Any docs updates needed?

@yuandrew yuandrew requested a review from a team as a code owner December 9, 2024 23:03
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Can you add an integration test that has a full history that replays successfully in the replayer, then confirm it continually succeeds in a replayer popping one event off the end each time?

Also, would like @Quinn-With-Two-Ns to look at this PR when he's available before we merge.

Comment on lines +537 to +539
func isTaskCompletedEvent(event *historypb.HistoryEvent) bool {
return event.GetEventType() == enumspb.EVENT_TYPE_WORKFLOW_TASK_COMPLETED
}
Copy link
Member

Choose a reason for hiding this comment

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

Just inline this single-use-single-line function, no need for a separate function

@@ -1045,6 +1050,9 @@ ProcessEvents:
binaryChecksum := nextTask.binaryChecksum
nextTaskBuildId := nextTask.buildID
admittedUpdates := nextTask.admittedMsgs
if len(reorderedEvents) > 0 && isTaskCompletedEvent(reorderedEvents[0]) {
Copy link
Member

Choose a reason for hiding this comment

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

I didn't check the code, but I assume you have confirmed that for every event set, the initial index is where the task completed event lives? Is there ever a situation in the Go SDK besides partial task during worker replayer where reorderedEvents[0] is not task completed? Are there any concerns about some of this logic affecting non-replayer code paths?

Comment on lines +1206 to +1210
// We do not want to run non-determinism checks on a task start that
// doesn't have a corresponding completed task.
if completedTaskCommandIndex >= 0 {
replayCommands = replayCommands[:completedTaskCommandIndex]
}
Copy link
Member

Choose a reason for hiding this comment

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

Basically same question from above, is there ever a case this if evaluates to true when not using a replayer (i.e. in normal operation)?

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.

Erroneous extra replay command when replaying mid-workflow tasks
2 participants