Skip to content

Conversation

spkane31
Copy link
Contributor

@spkane31 spkane31 commented Jun 25, 2025

What changed?

add a timestamp to the TriggerImmediately schedule for use instead of now()

Why?

We can make the wft “more idempotent”: put the desired trigger time in the trigger immediately request itself, so it goes in the signal payload, so all wfts attempt to start the target with the same id.

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

TBD @dnr @lina-temporal

@spkane31 spkane31 requested a review from a team as a code owner June 25, 2025 15:17
spkane31 added a commit to temporalio/api that referenced this pull request Jun 25, 2025
_**READ BEFORE MERGING:** All PRs require approval by both Server AND
SDK teams before merging! This is why the number of required approvals
is "2" and not "1"--two reviewers from the same team is NOT sufficient.
If your PR is not approved by someone in BOTH teams, it may be summarily
reverted._

<!-- Describe what has changed in this PR -->
**What changed?**
adding a timestamp to `TriggerImmediatelyRequest` message

<!-- Tell your future self why have you made these changes -->
We can make the wft “more idempotent”: put the desired trigger time in
the trigger immediately request itself, so it goes in the signal
payload, so all wfts attempt to start the target with the same id.


<!-- Are there any breaking changes on binary or code level? -->
**Breaking changes**


<!-- If this breaks the Server, please provide the Server PR to merge
right after this PR was merged. -->
[**Server PR**](temporalio/temporal#7968)
temporal-cicd bot pushed a commit to temporalio/api-go that referenced this pull request Jun 25, 2025
_**READ BEFORE MERGING:** All PRs require approval by both Server AND
SDK teams before merging! This is why the number of required approvals
is "2" and not "1"--two reviewers from the same team is NOT sufficient.
If your PR is not approved by someone in BOTH teams, it may be summarily
reverted._

<!-- Describe what has changed in this PR -->
**What changed?**
adding a timestamp to `TriggerImmediatelyRequest` message

<!-- Tell your future self why have you made these changes -->
We can make the wft “more idempotent”: put the desired trigger time in
the trigger immediately request itself, so it goes in the signal
payload, so all wfts attempt to start the target with the same id.

<!-- Are there any breaking changes on binary or code level? -->
**Breaking changes**

<!-- If this breaks the Server, please provide the Server PR to merge
right after this PR was merged. -->
[**Server PR**](temporalio/temporal#7968)
@spkane31 spkane31 requested a review from dnr June 25, 2025 19:32
@spkane31 spkane31 requested a review from dnr June 27, 2025 01:21
{
at: time.Date(2022, 6, 1, 0, 30, 0, 0, time.UTC),
f: func() {
// this one runs with overridden overlap policy
s.env.SignalWorkflow(SignalNamePatch, &schedulepb.SchedulePatch{
TriggerImmediately: &schedulepb.TriggerImmediatelyRequest{
ScheduledTime: timestamppb.New(time.Date(2022, 6, 1, 0, 30, 0, 0, time.UTC)),
Copy link
Contributor

Choose a reason for hiding this comment

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

should we change the value to check that it's actually used?

I think then we'll need to bump the current version in this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing the ScheduledTime to ScheduledTime: timestamppb.New(time.Date(2022, 6, 1, 0, 40, 0, 0, time.UTC)), will cause the test to fail with:

            	Error Trace:	/Users/seankane/git/github.com/temporalio/temporal/service/worker/scheduler/workflow_test.go:305
            	            				/Users/seankane/git/github.com/temporalio/temporal/service/worker/scheduler/workflow_test.go:1137
            	Error:      	Not equal: 
            	            	expected: 2
            	            	actual  : 1
            	Test:       	TestWorkflow/TestTriggerImmediate
            	Messages:   	started map[string]time.Time{"myid-2022-06-01T00:15:00Z":time.Date(2022, time.June, 1, 0, 15, 0, 0, time.UTC)}

I think that shows it's used as we expect. I don't see a way to indicate a test should fail though so I'm not sure what the change here should be

@spkane31 spkane31 requested a review from dnr June 27, 2025 17:25
@spkane31 spkane31 merged commit a6851ab into main Jun 27, 2025
85 of 87 checks passed
@spkane31 spkane31 deleted the spk/trigger-immediately-bug branch June 27, 2025 17:47
@spkane31 spkane31 self-assigned this Jul 1, 2025
yycptt pushed a commit to temporalio/api that referenced this pull request Aug 4, 2025
_**READ BEFORE MERGING:** All PRs require approval by both Server AND
SDK teams before merging! This is why the number of required approvals
is "2" and not "1"--two reviewers from the same team is NOT sufficient.
If your PR is not approved by someone in BOTH teams, it may be summarily
reverted._

<!-- Describe what has changed in this PR -->
**What changed?**
adding a timestamp to `TriggerImmediatelyRequest` message

<!-- Tell your future self why have you made these changes -->
We can make the wft “more idempotent”: put the desired trigger time in
the trigger immediately request itself, so it goes in the signal
payload, so all wfts attempt to start the target with the same id.


<!-- Are there any breaking changes on binary or code level? -->
**Breaking changes**


<!-- If this breaks the Server, please provide the Server PR to merge
right after this PR was merged. -->
[**Server PR**](temporalio/temporal#7968)
yycptt pushed a commit to temporalio/api-go that referenced this pull request Aug 4, 2025
_**READ BEFORE MERGING:** All PRs require approval by both Server AND
SDK teams before merging! This is why the number of required approvals
is "2" and not "1"--two reviewers from the same team is NOT sufficient.
If your PR is not approved by someone in BOTH teams, it may be summarily
reverted._

<!-- Describe what has changed in this PR -->
**What changed?**
adding a timestamp to `TriggerImmediatelyRequest` message

<!-- Tell your future self why have you made these changes -->
We can make the wft “more idempotent”: put the desired trigger time in
the trigger immediately request itself, so it goes in the signal
payload, so all wfts attempt to start the target with the same id.

<!-- Are there any breaking changes on binary or code level? -->
**Breaking changes**

<!-- If this breaks the Server, please provide the Server PR to merge
right after this PR was merged. -->
[**Server PR**](temporalio/temporal#7968)
yycptt pushed a commit that referenced this pull request Aug 5, 2025
## What changed?
add a timestamp to the `TriggerImmediately` schedule for use instead of
now()

## Why?
We can make the wft “more idempotent”: put the desired trigger time in
the trigger immediately request itself, so it goes in the signal
payload, so all wfts attempt to start the target with the same id.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [x] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks

TBD @dnr  @lina-temporal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants