234 Commits

Author SHA1 Message Date
Stephan Behnke
5aa7a471d8 Make Nexus log messages aggregatable (#11765)
## What changed

Kept dynamic data out of Nexus log messages and moved it to tags. Added
a review guideline requiring static logger messages and structured tags
for all dynamic content.

## Why

Ensures that Nexus logs are aggregatable.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-27 15:07:29 -07:00
Prathyush PV
ceb1cc1071 Validate history pagination branch token against mutable state (#11723)
## What changed?
`GetWorkflowExecutionHistory` and `GetWorkflowExecutionHistoryReverse`
now check `branch_token` in the page token against the token in mutable
state.

## Why?
To confirm if it is still the correct branch after conflict resolution.

## How did you test it?
- [x] built
- [x] run locally and tested manually
- [x] covered by existing tests
- [x] added new unit test(s)
- [x] added new functional test(s)
2026-08-21 13:41:54 -07:00
Stephan Behnke
612823d3ea Log outbound queue circuit breaker state changes (#11661)
### What changed
Sets gobreaker's OnStateChange hook on the outbound queue circuit
breaker pool, logging every transition.

### Why
Obtain more details for debugging curcuit breaker in production.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 03:16:03 +00:00
Stephan Behnke
b1d6efc0a7 Tag Nexus pre-dispatch failure logs (#11664)
## What changed

Adds logs tags for failures on the Nexus frontend path.

## Why

Have more details to correlate issues with requests.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 17:27:43 -07:00
Stephan Behnke
f1c8590f68 Add Nexus operation context to handler-side logs (#11663)
## What changed

Adds a few Nexus-specific log tags to the handler-side frontend logger.

## Why

Mainly for the request ID to debug Nexus calls across namespaces better.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 17:27:32 -07:00
Shahab Tajik
da4185bfc4 Fix concurrent map crash when logging slow namespace callbacks (#11258)
## What

The slow-callback warning in `(*registry).RegisterStateChangeCallback`
formatted the callback key with `fmt.Sprintf("%v", key)`:

```go
r.logger.Warn(
    "Namespace registry callback slow",
    tag.Key(fmt.Sprintf("%v", key)),
    tag.Duration("duration", duration),
)
```

Callback keys are arbitrary values and are usually the registrant itself
(e.g. `*WorkflowHandler`, `*historyEngineImpl`, the queue scheduler).
`%v` deep-prints the entire struct via reflection, and when that
traversal iterates an internal map that another goroutine is writing,
the Go runtime aborts the **whole process**:

```
fatal error: concurrent map iteration and map write
...
fmt.Sprintf(...)
nsregistry.(*registry).RegisterStateChangeCallback.func1.1()  registry.go:298
```

This is a `fatal()`, not a recoverable panic, so the `goro.Handle`
recover at the top of the goroutine cannot catch it — the frontend
crashes.

## Fix

Replace the format call with `formatCallbackKey`, which:
- prints scalar keys (string/number/bool) by value,
- prints `fmt.Stringer` keys (e.g. `uuid.UUID`, used by the
namespace-handover interceptor) via `String()`,
- renders everything else as `type(0xADDR)` for pointer-like kinds, or
just the type name otherwise — **never traversing fields**.

This keeps the log useful (you can still tell which registrant was slow)
while eliminating the reflection walk that caused the race.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-24 15:47:31 -07:00
Stephan Behnke
a6b196e98c Add log tags to CHASM Nexus failure log (#11009)
## What changed?

The `Nexus StartOperation/CancelOperation request failed` logs for CHASM
only attached `tag.Error(callErr)` and are missing helpful context.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-16 17:56:16 +00:00
Yichao Yang
6e424eaa22 Global RPS Control for Admin Batch Operation (#10546)
## What changed?
- Add host level rate limiter for controlling RPS of admin batch
operations across all namespaces and all admin batch workflows.

## Why?
- When running admin batch operations we only care about controlling the
total RPS, not really RPS for a given namespace or a given admin batch
workflow.

## How did you test it?
- [x] built
- [x] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-06-05 12:48:49 -07:00
David Reiss
d69aede7e5 Dynamic partitioning: scale manager (#10365)
## What changed?
Add scale manager component.

## Why?
Part of dynamic partitioning.

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

## Potential risks
No behavior changes yet.
2026-06-04 17:34:25 -07:00
feiyang
c5badc94b5 time-skipping runtime foundation (#9965)
## What changed?

1) `taskGenerator`: 
- add regenerate tasks for time skipping
2) `mutableState`: 
- new methods: add key methods to transition time
- `IsStateDirty`: captures changes of time-skipping related fields
- `closeTransaction`: add closeTransactionHandlerTimeSkipping 
3) event: new time-skipping runtime event added 
4) persistence: new runtime data added to execution info

 ## Why?

add the foundational mechanism of how time skipping works in the runtime
of a workflow execution

**for reviewers:** 
this is a foundation of t-s runtime, so it works without any granular
and extended features as bound, replication, external-transfer tasks,
etc. **Over 50% of lines are tests/mocks/pb-gen. can focus on code
first, then functional tests, and last ut.**

## How did you test it?
- [x] built
- [x] run locally and tested manually
- [x] covered by existing tests
- [x] added new unit test(s)
- [x] added new functional test(s)
2026-04-17 11:44:52 -07:00
Sean Kane
9030019c6a tests: write debug level logs to a file (#9608)
## What changed?
Functional tests write debug-level logs to a file rather than inline in
the job. Info and above are still visible and the debug logs are
available for download at the end of each test job.

## Why?
Debug level logs make parsing the functional test run logs very
difficult, sometimes too large to even download the logs. This makes
debugging flaky test runs even more difficult.

## 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)
- [X] manually verified in CI

## Potential risks
Minimal, debug logs are still available to download and parse. If there
are logs that are missing for debugging we should move those from
`debug` to `info` level in the future
2026-03-23 21:12:18 +00:00
Stephan Behnke
88a9b616f8 OperationID, ChasmRunID and ActivityID log tags in interceptor (#9498)
## What changed?

Extend genrpcserverinterceptors to support `ActivityID` and
`OperationID` and `ChasmRunID`

## Why?

Fix and improve logging.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-03-13 21:02:53 +00:00
Vladyslav Simonenko
e5fcecc097 Fix throttled logger to not throttle panics and fatals (#9385)
## What changed?
Do not throttle panics and fatals in throttled logger

## Why?
The doc block for NewThrottledLogger already says:
```
// Fatal/Panic logs are always emitted without any throttling
```
but this is not respected in the code. Changed the code to match this.

## How did you test it?
- [X] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-03-09 15:17:30 -07:00
Stephan Behnke
5b49acfaf9 go fix (#9337)
## What changed?

Integrate Go 1.26's new `go fix` into workflow.

NOTE that the changes caused our linter to fire; a [separate
commit](1b23f787ae)
addresses those.

## Why?

Ensure Go code is standardized/modernized.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-02-18 09:12:19 -08:00
Tim Deeb-Swihart
e13ebf04cc chore: update code to use new log aliases where applicable (#9177)
## What changed?

This updates the server code to use the shorthand log tag constructors
introduced in #9174.

As part of this it _does_ make a breaking change to the `Bool`
constructor: it now takes in the key as a string to be consistent.

The only inconsistent one is now `Error`, but that's used so heavily
that changing it is likely not worth the time.


## Why?

Consistency!

## How did you test it?
Existing tests

## Potential risks
The only risk is that I _have_ introduced a breaking change to the Bool
constructor. I'm happy to undo that if my reviewers desire: my goal is
minimal breaking changes.

I'd prefer none, but I made this change to stir up discussion
2026-02-02 17:58:20 +00:00
Tim Deeb-Swihart
94247016ef log: add consistent, shorthand log tag constructors (#9174)
## What changed?

This PR adds _consistent_ shorthand tag constructors for all supported
zap tags.

I also added `Uint64` (and `NewUint64`) as we've wanted it in other
projects.

## Why?

There are two main reasons:
- I (and others I've talked to) are lazy and dislike typing
`log.New<Type><TAB>` when `log.<Type>` would have done it
- Consistency! Some tags are just the type name (`Bool`, `Error`), some
have a prefix of New (`NewInt64`), and some have a prefix _and_ a suffix
of Tag (`NewStringTag`).

The new constructors are entirely consistent: no prefixes and no
suffixes; just the type's name.

## How did you test it?
I didn't, yet. These wrap existing APIs.

## Potential risks
None.
2026-01-30 08:34:56 -05:00
Yichao Yang
32687799d7 CHASM: add panic wrapper for library logic (#8920)
## What changed?
- Add panic wrapper for library logic
- Also provides a logger through the Context interface

## Why?
- Capture panic error so that it's easier to tell where the panic
actually happens. Otherwise a panic can cause another panic in some
unrelated deferred function making debugging harder.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-01-16 07:02:29 +00:00
Yichao Yang
c897bdcbf6 CHASM: Do a final staleness check after reload (#8899)
## What changed?
- Do a final staleness check after reload

## Why?
- Due to data loss or force failover, it's possible that even after
reload the mutable state may still be stale.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-01-05 17:00:42 -08:00
Shahab Tajik
9f94f316fd Refactor worker-build-id metrics tag. (#8936)
## What changed?
- Rename the tag from `worker-build-id` -> `worker_version`.
Use `:` instead of `/` in the tag value.

## Why?
Consistent terminology and delimiter.

## 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
Self hosted clusters relying on the old tag name and values would have
to adopt new tag. This should be ok because versioning is not GA yet.
2026-01-05 13:48:17 -08:00
Fred Tzeng
41593fe137 Consolidated and refactored activity request validations. (#8508)
Consolidated and refactored activity request validations to the chasm
package.
Added additional tests for the validator.

Existing workflow activities and standalone activities should share the
same validation code. Standalone activities also directly process the
frontend request and therefore has additional fields to validate
compared to embedded activities.

- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [X] added new unit test(s)
- [ ] added new functional test(s)

This refactors the existing stack, but the validation is basically
exactly copied over and all relevant tests are passing. The standalone
start activity request is now cloned before sanitizing the request
attributes to preserve idempotent behavior during retries, but can
potentially impact performance if there are large inputs.

---------

Co-authored-by: Roey Berman <roey.berman@gmail.com>
2025-12-19 11:01:46 -05:00
Yichao Yang
0c2b360e40 CHASM: Propagate ArchetypeID (#8693)
## What changed?
- Use archetypeID everywhere in history service and pass them to
persistence

## Why?
- Required for separate ID space work.

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [x] added new unit test(s)
- [ ] added new functional test(s)
2025-11-26 16:04:44 -08:00
Chetan Gowda
9494ded710 Mutable state changes for unpausing a single workflow. (#8674)
## What changed?
- Recording unpause event
- Regenerating workflow and activity tasks
- Made EVENT_TYPE_WORKFLOW_EXECUTION_UNPAUSED a buffered event (since
pause event is buffered)
- Added unit tests (Functional tests are added along with the API
changes)

## Why?
This is needed to implement pause/unpause operation APIs.

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



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Introduce workflow "unpaused" history event end-to-end, buffer
pause/unpause consistently, and reschedule activities on unpause with
tests.
> 
> - **History Events**:
> - Add `CreateWorkflowExecutionUnpausedEvent` and
`HistoryBuilder.AddWorkflowExecutionUnpausedEvent`.
> - Update event buffering: buffer both `WORKFLOW_EXECUTION_PAUSED` and
`WORKFLOW_EXECUTION_UNPAUSED` in `historybuilder/event_store.go`.
> - **Mutable State**:
> - Add `AddWorkflowExecutionUnpausedEvent` and
`ApplyWorkflowExecutionUnpausedEvent` to transition to `RUNNING`, clear
`PauseInfo`, bump activity stamps, and (re)generate activity tasks as
needed.
>   - Extend `interfaces.MutableState` + mocks with unpause methods.
>   - Rebuilder applies `WORKFLOW_EXECUTION_UNPAUSED` events.
> - **Logging/Tags**:
>   - Add `tag.WorkflowActionWorkflowUnpaused`.
> - **Tests**:
> - Add unit tests for pause/unpause flow, stamps, and buffering
behavior; adjust existing buffering test expectations.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f13902700e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Sean Kane <spkane31@gmail.com>
2025-11-22 13:07:14 -08:00
Chetan Gowda
d9d2f62bed Mutable state changes for workflow pause. (#8560)
## What changed?
**Note**: This depends on https://github.com/temporalio/api/pull/653.
Sending it for some early feedback.
- Made changes to `WorkflowPauseInfo` (in WorkflowExecutionInfo).
Reusing unused proto fields.
- Added mutablestate.IsWorkflowExecutionPaused()
- Added mutablestate.AddWorkflowExecutionPausedEvent()

## Why?
- These changes are needed to implement pause/unpause features.

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



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds workflow-level pause/unpause with new `WorkflowPauseInfo` fields,
client endpoints, history event handling, state/status validation for
`PAUSED`, and tests; removes activity-level pause info.
> 
> - **Protocol/API**:
> - Redefine `persistence.v1.WorkflowPauseInfo` to `{pause_time,
identity, reason, request_id}`; remove `ActivityPauseInfo` and related
helpers.
> - Bump dependency `go.temporal.io/api` and adjust generated code
indexes.
> - Update RPC metadata, redirection maps, quotas, and log tags for
`PauseWorkflowExecution`/`UnpauseWorkflowExecution`.
> - **Frontend Clients**:
> - Add `PauseWorkflowExecution` and `UnpauseWorkflowExecution` to
`client_impl`, `metric_client`, `retryable_client`, and mocks.
> - **History/State**:
> - Add `WorkflowExecutionPaused` event creation
(`Create/Add...PausedEvent`) with buffering rules (paused allowed to
buffer; unpaused not buffered).
> - Implement `ApplyWorkflowExecutionPausedEvent`: set status `PAUSED`,
populate `executionInfo.PauseInfo`, invalidate pending activities and
workflow task via stamps.
> - Rebuilder applies paused event; state transition validation supports
`PAUSED` across CREATED/RUNNING/ZOMBIE.
> - **Validation/Tests**:
> - Allow `WORKFLOW_EXECUTION_STATUS_PAUSED` in validators; expand unit
tests for create/update state/status and paused behavior.
> - **Tooling**:
>   - `buf.yaml` breaking ignore for `executions.proto`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
951c9c4a53. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-11-19 10:37:18 -08:00
Stephan Behnke
4b5c135304 Static softassert message (#8385)
## What changed?

Changed callers of softasserts that used a dynamic message to use a
static message; and pass rest in through tags.

NOTE: I've experimented with https://github.com/quasilyte/go-ruleguard
to enforce it; but that is too brittle.

## Why?

It makes grouping in logs (and Antithesis) much easier as the identifier
is static.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2025-09-29 19:19:12 +00:00
Yichao Yang
840a1ea9bd CHASM: Enforce archetype check (#8011)
## What changed?
- Enforce archetype when loading mutable state

## Why?
- Avoid workflow operation get applied to non-workflow archetypes.

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2025-07-17 15:39:01 -07:00
Yuri
d925a3ab73 Route heartbeats from Poll/ShutDown (#8000)
## What changed?
Route heartbeats, if present, from Poll...and ShutdownWoker frontend
handle to the corresponding matching instance.

## Why?
We piggyback on Poll/Shutdown for heartbeats to reduce the number of
separate API calls.

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

## Potential risks
Latency increate? One of the possible solution will be to make those
calls async in "fire and forget" style.
2025-07-09 22:13:25 -07:00
Paul Nordstrom
3dc217c907 This PR changes log.With(logger, tags ...) to "upsert" the supplied Tags (based on their keys) (#7945)
## What changed?
this PR changes the semantics of common/log/Logger to apply With(tags)
as upserts for duplicate keys, rather than appending duplicates. This
matches the behavior of the TestLogger
## Why?
Having multiple values for the same Tag key in the logs is much more
confusing than helpful.

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

## Potential risks
- It's possible someone is dependent on the existing behavior and may
need to adjust. However, this shouldn't affect functionality.
- Each Logger instance consumes a bit more memory
2025-06-25 10:47:14 -07:00
Tim Deeb-Swihart
101091a6b4 testlogger: actually fail tests when we're supposed to (#7874)
## What changed?

This changes all methods that fail tests on the test logger to
**forcibly** fail it by calling `t.Fatalf`.

It adds the stack trace to the failure message as we'd otherwise have no
information on the _path_ to the failure, which is why we initially used
`panic`

## Why?

While testing a separate project I determined that panics from OSS' test
logger (and the internal one it is based on!) were being caught by our
application code, obscuring issues that should cause tests to fail.

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

## Potential risks

This may fail more tests than we currently do. This is a Good Thing.
2025-06-10 15:54:58 -04:00
Lina Jodoin
70a5a4cf75 Move a few occurrences of variables logged inline into tags (#7767)
## What changed?
Updated (most) log statements that log variables inline to use
structured logging. There were occurrences that I left untouched, as I
felt that the inline logging added siginficant clarity over a tag.

Prompt history (`claude-3.7-sonnet`):

> Although our logger supports structured logging via its tags, many of
our error messages instead emit variable data directly into the text
content of the logged message.
> Can you find occurrences of messages being logged with variable data
directly in the textual portion, and instead move those variables into
tags on the message, to facilitate structured logging?
>
> Please limit changes you make to precisely this ask; if no tags are
changed on a log statement, don't rewrite the message.
> 
> The scope should be the *entire* codebase.

...

> Great - are there any other places in the whole codebase you can see
where we're dynamically formatting error strings with variables in log
statements?

...

> Can you make those changes?

...

> Complete that codebase-wide refactoring initiative.

...

> Great. Are there any other places that are still logging with format
strings that include variables, anywhere in the codebase?

... 

Bonus robot chatter:

<img width="379" alt="Screenshot 2025-05-14 at 10 51 05 AM"
src="https://github.com/user-attachments/assets/8f1c8a73-3c9b-4d5e-bccd-b37ef8165d9c"
/>

## 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)
2025-06-03 17:59:55 +00:00
Shahab Tajik
1f75c8eb00 Change Deployment Version SA delimiter to : (#7806)
## What changed?
Change Deployment Version SA delimiter from `.` to `:`.

## Why?
New delimiter is used in:
- `TemporalWorkerDeploymentVersion` SA
- `BuildIds` SA, for the `pinned:<deployment name>:<build id>` format
- Deployment Version workflow ID

Old delimiter is used in:
- v31 version string values in external API
- version string values in internal entity workflows and APIs

We'll refactor code to clean up usage of old delimiter and string
version fields later. For now, the priority is to make public preview
external APIs consistent.

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

## Potential risks
If Versioning V0.31 pre-release users directly use these SAs, they wont
be able to find old or new wfs if they filter using only one of the
delimiters. (This affects "Go to Workflow" links in UI until UI is
updated)
2025-05-30 04:09:26 +03:00
Tim Deeb-Swihart
6141dd6d60 chore: be smarter about when to use Stringer vs String (#7743)
## What changed?

I've changed _some_ of the tags I altered in #7738 back to StringTags
from StringerTags and added usage recommendations to the StringerTag
(and StringersTag) methods.

## Why?

@prathyushpv rightly pointed out that some of the tags I changed in
#7738 are applied to the loggers themselves and not just the messages.
This means that the `String()` method will be invoked _every time_ a log
is to be emitted. This incurs extra allocations etc. etc.
2025-05-09 13:40:35 -04:00
Tim Deeb-Swihart
3dcdfde5ac chore: Add Stringer tags (#7738)
## What changed?

This PR adds easy access to Zap's Stringer and Stringers fields.

## Why?

`Stringer` fields are more efficient than `String` field. In the OSS
repo alone we have 22 separate invocations of `tag.NewStringTag(...,
foo.String())` which would be better served by using a Stringer tag.
This only calls `String` (which can be expensive) when the line is
actually emitted.

Meaning fewer wasted cycles when calling `String()` for debug-level
logs.


## How did you test it?
- [x] I'm doing this manually elsewhere
2025-05-08 19:45:52 +00:00
Alex Shtin
91893f1064 Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00
Stephan Behnke
ed11745e98 Upgrade mockgen (#7527)
## What changed?
<!-- Describe what has changed in this PR -->

Upgraded mockgen.

## Why?
<!-- Tell your future self why have you made these changes -->

Dependency hygiene. 

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

CI.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2025-03-25 21:33:08 +00:00
Shivam
50698f69c2 versioning flakes pt2 (#7473)
## What changed?
<!-- Describe what has changed in this PR -->
fixed some code to reduce versioning flakes, mainly:

[TestVersioning3FunctionalSuite/TestUnpinnedWorkflowWithRamp_ToUnversioned](https://github.com/temporalio/temporal/actions/runs/13818885947/job/38659266639)
(with_logger data-race )


[TestWorkerDeploymentSuite/TestSetWorkerDeploymentRampingVersion_Unversioned_VersionedCurrent](https://github.com/temporalio/temporal/actions/runs/13818885947/job/38659261367)
( context timeout - maybe fixed by having a separate go-routine  )


[TestDeploymentVersionSuite/TestDrainageStatus_SetCurrentVersion_YesOpenWFs](https://github.com/temporalio/temporal/actions/runs/13818885947/job/38659258964)
(with_logger data-race )

[TestVersioningFunctionalSuite/TestDispatchActivityFailCrossTq (retry
2)](https://github.com/temporalio/temporal/actions/runs/13712084173/job/38350437309)
(with_logger data-race )


## Why?
<!-- Tell your future self why have you made these changes -->
- To stop these from appearing as flakes in the test reports.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
- Ran this locally with `-race` and now see no errors (errored out
previously)
- Ran this on CI a bunch of times without errors/flakes

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2025-03-17 12:38:07 -04:00
pdoerner
5ea40d9284 Add HTTP tracing to forwarded Nexus requests (#7428)
## What changed?
<!-- Describe what has changed in this PR -->
Added additional tracing logs for forwarded Nexus HTTP requests.

## Why?
<!-- Tell your future self why have you made these changes -->
Forwarded requests create a new request so they were not copying over
the `httptrace.ClientTrace` set in the executors.
2025-03-06 18:50:30 +00:00
Stephan Behnke
7d5138b7d0 Port previous NewTestLogger flags over (#7432)
## What changed?
<!-- Describe what has changed in this PR -->

Ports `TEMPORAL_TEST_LOG_FORMAT` and `TEMPORAL_TEST_LOG_LEVEL` to
testlogger.TestLogger.

## Why?
<!-- Tell your future self why have you made these changes -->

To not break developer setups.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2025-03-06 08:37:18 -08:00
Stephan Behnke
d866361f8f Assertion function and TestLogger (#7411)
## What changed?
<!-- Describe what has changed in this PR -->

- Added a new function `softassert.That` that logs an error if the
provided condition is false
- Added `testlogger.Testlogger` (copied and slightly modified from our
internal repository) to functional tests

## Why?
<!-- Tell your future self why have you made these changes -->

To allow developers to verify pre- and post-conditions in their code.

**Why not panic?** Maybe in the future. For now, we're happy with
finding these failed assertions in functional tests.

**What about nightlies/long-haul tests?** I've filed a ticket to detect
a failed assertion there and surface them as an alert.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

Planted a failing assertion.

**The error log:**
```
logger.go:146: 2025-03-04T20:50:08.578Z	ERROR	log/zap_logger.go:154	Unexpected Error log encountered: failed assertion: wake called twice	{"host": "127.0.0.1:35427", "component": "matching-engine", "wf-task-queue-name": "/_sys/temporal-sys-processor-parent-close-policy/1", "wf-task-queue-type": "Workflow", "wf-namespace": "temporal-system", "worker-build-id": "_unversioned_", "failed-assertion": true, "logging-call-at": "/home/runner/work/temporal/temporal/common/log/with_logger.go:72"}
        go.temporal.io/server/common/log.(*zapLogger).Error
        	/home/runner/work/temporal/temporal/common/log/zap_logger.go:154
        go.temporal.io/server/common/testing/testlogger.(*TestLogger).Error
        	/home/runner/work/temporal/temporal/common/testing/testlogger/testlogger.go:359
        go.temporal.io/server/common/log.(*withLogger).Error
        	/home/runner/work/temporal/temporal/common/log/with_logger.go:72
        go.temporal.io/server/common/log.(*withLogger).Error
        	/home/runner/work/temporal/temporal/common/log/with_logger.go:72
        go.temporal.io/server/common/log.(*withLogger).Error
        	/home/runner/work/temporal/temporal/common/log/with_logger.go:72
        go.temporal.io/server/common/log.(*withLogger).Error
        	/home/runner/work/temporal/temporal/common/log/with_logger.go:72
        go.temporal.io/server/common/softassert.That
        	/home/runner/work/temporal/temporal/common/softassert/softassert.go:50
        go.temporal.io/server/service/matching.(*waitableMatchResult).wake
        	/home/runner/work/temporal/temporal/service/matching/matcher_data.go:560
```


https://github.com/temporalio/temporal/actions/runs/13662479940/job/38196953773?pr=7411#step:9:1638

**The test result:**
```
=== Failed
=== FAIL: tests TestPriorityFairnessSuite/TestPriority_Activity_Basic (0.00s)
    functional_test_base.go:301: Running TestPriorityFairnessSuite/TestPriority_Activity_Basic in test shard 2/3
    functional_test_base.go:373: 
        	Error Trace:	/home/runner/work/temporal/temporal/tests/testcore/functional_test_base.go:373
        	            				/home/runner/work/temporal/temporal/tests/testcore/functional_test_base.go:272
        	            				/home/runner/work/temporal/temporal/tests/testcore/functional_test_base.go:254
        	            				/home/runner/work/temporal/temporal/tests/testcore/functional_test_sdk_suite.go:97
        	            				/home/runner/go/pkg/mod/github.com/stretchr/testify@v1.10.0/suite/suite.go:192
        	Error:      	Failing test as unexpected error logs were found.
        	            	Look for 'Unexpected Error log encountered'.
        	Test:       	TestPriorityFairnessSuite/TestPriority_Activity_Basic
```

https://github.com/temporalio/temporal/actions/runs/13662479940/job/38196953773?pr=7411#step:9:1053


## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->

---------

Co-authored-by: David Reiss <david@temporal.io>
Co-authored-by: David Reiss <dnr@dnr.im>
Co-authored-by: Tim Deeb-Swihart <409226+tdeebswihart@users.noreply.github.com>
2025-03-05 19:02:44 +00:00
pdoerner
2640635bd9 Add tracing logs for Nexus HTTP request retries (#7186)
## What changed?
<!-- Describe what has changed in this PR -->
Added additional HTTP tracing logs for the first 3 Nexus request
retries.
Both minimum and maximum attempts to add additional tracing info to are
configurable.

## Why?
<!-- Tell your future self why have you made these changes -->
To aid in debugging.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2025-02-06 15:35:27 -08:00
Roey Berman
5d68b3ac34 Fix a couple of issues in the slog adapter (#7000)
## What changed?

- Always carry over the embedded `zapLogger`.
- Ensure `handler` is never `nil`.
- Allow extracting an underlying `slog.Logger`.

## Why?

Realized there are some issues using custom loggers, like the one used
by the CLI.
2024-12-17 10:40:25 -08:00
David Reiss
72309bbd74 Merge versioning-3 branch into main (#6890)
Co-authored-by: ShahabT
2024-11-27 17:51:41 -08:00
Shahab Tajik
ba07427e4a Support unpinned workflows (#6887)
## What changed?
<!-- Describe what has changed in this PR -->
Add Matching and History changes to properly route unpinned workflow
tasks.

## Why?
<!-- Tell your future self why have you made these changes -->

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Tests will come in separate PR.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2024-11-26 22:34:04 -08:00
Carly de Frondeville
7036092063 UpdateWorkflowExecutionOptions API (#6822)
## What changed?
- Implement UpdateWorkflowExecutionOptions API
## Why?
So users of versioning can override versioning behavior and deployment
for specific workflow executions for debugging or finer grained control.

## How did you test it?
- Unit tests for field mask logic
- Mutable state suite tests to confirm that Adding the event gets
applied correctly
- Todo: functional tests in a side branch using versioning-3 sdk, when
it's ready

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->

---------

Co-authored-by: ShahabT <shahab.tajik@temporal.io>
Co-authored-by: Shahab Tajik <shahab@temporal.io>
2024-11-26 15:20:46 -08:00
Stephan Behnke
be826af46a OTEL workflow span attributes (#6699)
## What changed?
<!-- Describe what has changed in this PR -->

**(1)** Adds the following OpenTelemetry (OTEL) span attributes:
- `temporalWorkflowID`
- `temporalRunID`

These are the same OTEL attribute keys the SDKs emit. It makes sense to
me to make them the same for consistency.

**(2)** Replaces the deprecated approach of OTEL interceptors with
`stats.Handler`s

**(3)** If there are no exporters, disables the `stats.Handlers`
completely. Right now we run through the OTEL processing even if it's
disabled.

## Why?
<!-- Tell your future self why have you made these changes -->

Right now there is no way to query all spans for a workflow together.

The newly added span attribute allows to correlate spans that belong to
the same workflow execution.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

(1) Added unit tests

(2) Manually

Using 
```
docker run -p 127.0.0.1:4317:4317 -p 127.0.0.1:55679:55679 otel/opentelemetry-collector:0.106.1 2>&1 | tee collector-output.txt
```
it outputs

<img width="591" alt="image"
src="https://github.com/user-attachments/assets/0a1dfcc3-b3ae-49b7-bd0b-9667e8ef3945">

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

It appears to be **no** breaking change. (ie same OTEL attributes as
before)

<img width="2011" alt="Screenshot 2024-10-26 at 10 00 41 AM"
src="https://github.com/user-attachments/assets/c871eeac-ed7b-428e-9c0a-425c796d8761">

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2024-11-04 16:45:07 +00:00
David Reiss
8ab9531593 Added logging to task queue user data propagation (#6456)
## What changed?
Add more logging around task queue user data propagation RPCs.
Also add a unit test that runs through the basic propagation logic.

## Why?
Add visibility to the process to help debug unusual behavior.

## How did you test it?
Added a unit test.
2024-09-24 15:10:03 -07:00
Yichao Yang
0e050a39ec Switch to uber gomock (#6493)
## What changed?
<!-- Describe what has changed in this PR -->
- Switch to uber gomock
- Generate workflowservice and operatorservice mock inside server repo,
instead of using imports from api-go to avoid making breaking changes
there.

## Why?
<!-- Tell your future self why have you made these changes -->
- google gomock is no longer maintained and doesn't support generics

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2024-09-09 14:44:20 -07:00
Jacob Barzee
0836b0fff0 Import alignment (#6426)
## What changed?
Make import formatting a part of the build, and test validity with
"ensure-no-changes" target

## Why?
So we never discuss import order again (hopefully)

## How did you test it?
its a build change, so the build will test it!

## Potential risks
As long as build works, the only thing I risk is the ire of coworker who
want imports to be different ;)

## Documentation
N/A

## Is hotfix candidate?
No
2024-08-23 14:48:10 -06:00
Chetan Gowda
48c17dcb13 Include full file path in logging-call-at field (#6326) 2024-07-23 17:32:57 -07:00
Hai Zhao
955339876b add BackfillHistoryTask (#6220)
## What changed?
This PR adds BackfillHistoryTask when SyncVersionedTransitionTask is not on current transition history.

## Why?
This PR is part of SyncVersionedTransitionTask.

## How did you test it?
unittest.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2024-07-23 15:31:12 -07:00
Alex Shtin
3b0fae7f1e Clear sticky task queue on speculative WFT error (#6295)
## What changed?
<!-- Describe what has changed in this PR -->
Clear sticky task queue on speculative WFT error.

## Why?
<!-- Tell your future self why have you made these changes -->
If, while completing WFT, error is occurred and returned to the worker
then worker will clear its cache. New WFT will also be created on sticky
task queue and sent to worker. Because worker doesn't have a workflow in
cache, it needs to replay it from the beginning, but sticky WFT has only
partial history. Worker will request full history using
`GetWorkflowExecutionHistory` API. This history doesn't have speculative
WFT events. If WFT is speculative, then worker will see inconsistency
between history from it and full history, and will fail WFT.


![image](https://github.com/user-attachments/assets/7d8df668-ec82-4e90-a408-4266176f59bf)

To prevent unexpected WFT failure, server clears stickiness for this
workflow, next WFT will go to normal task queue, and will have full
history attached to it.
This is NOT 100% bulletproof solution because this write operation may
also fail.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Run in test environment with fault injection enabled.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
Not 100% bulletproof solution. Future work to improve
`GetWorkflowExecutionHistory` is needed.

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->
No.

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
No.
2024-07-22 06:10:34 +00:00