Skip to content

Conversation

@spkane31
Copy link
Contributor

@spkane31 spkane31 commented Dec 6, 2025

What changed?

When buffered events are applied, like when applying signals after workflow task failures occur, preserve the workflow task attempt so the TemporalReportedProblems search attribute is still properly added.

Why?

Without this change the TemporalReportedProblems search attribute will never be added if a workflow is consistently queried.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Potential risks

Minimal, this adds a new int to the workflow task execution, but it's only used in one place.

@spkane31 spkane31 requested review from a team as code owners December 6, 2025 00:11
@spkane31 spkane31 requested a review from bergundy December 9, 2025 21:10
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

@yycptt would you please also take a look? I'm less familiar with workflow tasks than you are. Also wondering if this covers replication properly, we are assuming state based replication is enabled for this.

Comment on lines 327 to 328
previousTotalFailures := m.ms.executionInfo.WorkflowTaskAttemptsSinceLastSuccess + m.ms.executionInfo.WorkflowTaskAttempt
m.ms.executionInfo.WorkflowTaskAttemptsSinceLastSuccess = previousTotalFailures
Copy link
Member

Choose a reason for hiding this comment

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

Can you update WorkflowTaskAttemptsSinceLastSuccess every time there is a WFT failure instead of only doing it when flushing buffered events? That seems more intuitive behavior to keep this attribute up-to-date.

// Start sending signals every second in a goroutine
signalDone := make(chan struct{})
go func() {
defer close(signalDone)
Copy link
Member

Choose a reason for hiding this comment

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

You could instead signal for a side effect in the workflow and immediately panic. No need to add concurrency to this test.

)
}

func (s *WorkflowTaskReportedProblemsReplicationSuite) TestWFTFailureReportedProblems_SetAndClear_FailAfterActivity() {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be also testing the buffered signal case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Duplicated the wrong test here, removing this.

Comment on lines 53 to 56
signalChan := workflow.GetSignalChannel(ctx, "test-signal")

var signalValue string
signalChan.Receive(ctx, &signalValue)
Copy link
Member

Choose a reason for hiding this comment

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

You don't really need to handle the signals in the workflow, it doesn't add value in the test and prevents your workflow task from failing because you never reach the line where it panics.

@spkane31 spkane31 requested a review from yycptt December 10, 2025 18:05
@spkane31 spkane31 requested a review from bergundy December 10, 2025 22:37
// This will create buffered.
if s.shouldFail.Load() {
// Signal ourselves to create buffered events
_ = workflow.SignalExternalWorkflow(ctx, workflow.GetInfo(ctx).WorkflowExecution.ID, "", "test-signal", "self-signal")
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't create buffered events, you need to do it from a workflow.SideEffect: https://pkg.go.dev/go.temporal.io/sdk/workflow#hdr-SideEffect_API

Copy link
Member

Choose a reason for hiding this comment

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

You will need to use a temporal client to issue the signal, and make sure you don't ignore errors, we should be able to tell that the signal was successfully submitted.

@semgrep-managed-scans
Copy link

Semgrep found 1 missing-explicit-permissions finding:

No explicit GITHUB_TOKEN permissions found at the workflow or job level. Add a permissions: block at the workflow root (applies to all jobs) or per job with least privilege (e.g., contents: read and only specific writes like pull-requests: write if needed).

@spkane31 spkane31 changed the title Preserve workflow task attempt when applying buffered events Fix TemporalReportedProblems SA application for buffered events Dec 12, 2025
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