Skip to content

fix(batcher): scope deterministic request IDs to the batch job ID - #11546

Merged
spkane31 merged 2 commits into
mainfrom
spk/batch-duplicate-bug
Aug 13, 2026
Merged

spkane31 merged 2 commits into
mainfrom
spk/batch-duplicate-bug

Conversation

@spkane31

Copy link
Copy Markdown
Contributor

What changed?

Use the jobID parameter in the deterministicRequestID function to allow multiple batch operations to signal the same workflow.

Why?

Two batch operations that send the same signal to the same workflow/run ID will only send one signal, the second will be de-duped in the signal logic because the request ID was hashed from workflow id / run id / signal name. Including the batch job ID gives proper hashing to prevent these separate signals from being de-duped

How did you test it?

  • added new unit test(s)
  • added new functional test(s)

Potential risks

NA, this is a bug fix.

@spkane31
spkane31 requested a review from a team August 13, 2026 16:13
@spkane31
spkane31 requested review from a team as code owners August 13, 2026 16:13
@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @spkane31's task in 3m 32s —— View job


Review of #11546

  • Read repo review guidelines (.github/copilot-instructions.md via the review skill)
  • Read the diff (git diff origin/main...HEAD)
  • Verified deterministicRequestID semantics and all four call sites
  • Posted findings inline

The fix is correct. All four call sites already passed batchOperation.Request.GetJobId(); the function just never wrote it into the hash key, so the doc comment ("derives a stable request ID from the batch job and the identifying fields of the target") described the intended behavior and the code didn't match it. JobId is guaranteed non-empty in practice — the frontend uses it as the batcher workflow ID (workflow_handler.go:5907) — and it is stable across activity retries and the batcher's continue-as-new, so retry dedupe within a job still works.

One blocking finding, left as an inline comment on the functional test.

Verification I could not do: go test ./service/worker/batcher/ and go vet ./tests/ were denied by tool permissions in this run, so I reviewed the tests by reading rather than executing them.
• branch spk/batch-duplicate-bug

Comment thread tests/workflow_api_batch_signal_test.go Resolved
@spkane31 spkane31 added the reliability-2026 Reliability related changes label Aug 13, 2026
@spkane31
spkane31 enabled auto-merge (squash) August 13, 2026 17:07
@spkane31
spkane31 marked this pull request as draft August 13, 2026 17:07
auto-merge was automatically disabled August 13, 2026 17:07

Pull request was converted to draft

@spkane31
spkane31 marked this pull request as ready for review August 13, 2026 17:07
@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @spkane31's task in 3m 13s —— View job


Review of #11546

  • Read repo review guidelines (.claude/skills/review/SKILL.md → .github/copilot-instructions.md)
  • Read the changes in pr-head/ (3 files)
  • Verified deterministicRequestID semantics and all four call sites
  • Checked JobId is guaranteed non-empty, and that nothing relies on cross-job dedupe
  • Reviewed the new unit + functional tests
  • Posted findings inline

The fix is correct. All four call sites already passed batchOperation.Request.GetJobId(); the function just never wrote it into the hash key, so the doc comment ("derives a stable request ID from the batch job and…") described intended behavior the code didn't implement. Supporting checks:

  • JobId cannot be empty: batcher.ValidateBatchOperation rejects it (service/worker/batcher/workflow.go:198) and the frontend uses it as the batcher workflow ID (service/frontend/workflow_handler.go:5907). So the key never degenerates back to the old job-independent form.
  • JobId is stable across activity retries and the batcher's continue-as-new, so retry dedupe within a job still works.
  • No server-side component starts a batch operation itself, so nothing depended on the previous cross-job dedupe. The only in-repo StartBatchOperation callers are the handler and its tests.
  • The functional test is a valid regression test: without the fix, the second job still reports success (request-ID dedupe is silent), and the workflow stays blocked on its second Receive until the 20s Get deadline.

The flaky-ordering issue from my earlier pass is resolved — the two jobs now run sequentially (tests/workflow_api_batch_signal_test.go:72-76), so the joined-result assertion has a deterministic order.

One finding, left as an inline comment on the new unit test.

Verification I could not do: git diff and go test ./service/worker/batcher/ were denied by tool permissions in this run, so I reviewed by reading the files in pr-head/ rather than executing tests.
• branch spk/batch-duplicate-bug

@spkane31
spkane31 merged commit 0d60f98 into main Aug 13, 2026
85 of 87 checks passed
@spkane31
spkane31 deleted the spk/batch-duplicate-bug branch August 13, 2026 17:12
@@ -607,6 +607,7 @@ func (a *activities) startTaskProcessor(
// lets the server's idempotency checks collapse retries of the same call.
func deterministicRequestID(jobID string, parts ...string) string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just remove jobID from this line? Or use four explicit params?

@awln-temporal awln-temporal mentioned this pull request Sep 4, 2026
5 tasks done
simvlad pushed a commit that referenced this pull request Sep 4, 2026
…1546)

## What changed?
Use the `jobID` parameter in the `deterministicRequestID` function to
allow multiple batch operations to signal the same workflow.

## Why?
Two batch operations that send the same signal to the same workflow/run
ID will only send one signal, the second will be de-duped in the signal
logic because the request ID was hashed from workflow id / run id /
signal name. Including the batch job ID gives proper hashing to prevent
these separate signals from being de-duped

## How did you test it?
- [x] added new unit test(s)
- [x] added new functional test(s)

## Potential risks
NA, this is a bug fix.

(cherry picked from commit 0d60f98)
simvlad added a commit that referenced this pull request Sep 4, 2026
## What changed?

Backports the 12 merged PRs labeled
[release/1.32.0](https://github.com/temporalio/temporal/issues?q=repo%3Atemporalio%2Ftemporal+is%3Apr+label%3Arelease%2F1.32.0)
that were not yet on `release/v1.32.x`, applied in `main` merge order.
Also fixes mixedbrain test by bumping go version to 1.26.8 in mixedbrain
folder (broken by #11928).

| # | PR | Author | What / Why |
|---|----|--------|------------|
| 1 | [#11546](#11546)
fix(batcher): scope deterministic request IDs to the batch job ID |
@spkane31 | Two batch operations sending the same signal to the same
workflow/run ID only delivered one — the request ID was hashed from
workflow ID / run ID / signal name, so the second was de-duped in signal
logic. Including the batch job ID in the hash keeps separate signals
distinct. |
| 2 | [#11642](#11642) Fix
batch operations targeting paused executions | @fretz12 | A paused
execution is still non-terminal, but the old `Running`-only filter
silently skipped paused targets. Users issuing a batch
terminate/signal/cancel reasonably expect it to apply to them. |
| 3 | [#11666](#11666) Fix
activity timeout regeneration after unpause | @fretz12 | Timeout tasks
that fired while an activity was paused were discarded, but the
activity's timer-task status still claimed they existed — preventing
recreation after unpause and potentially making the timeout ineffective.
Also fixes `ResetActivity` bypassing normal unpause handling, and
running activities returning early without clearing paused state. |
| 4 | [#11696](#11696) Treat
missing Worker Deployment Version as deleted | @rkannan82 | Treats
`NotFound` from the Version workflow delete update as success. When a
Version workflow is already closed or its history is gone, `NotFound`
blocked the Deployment workflow from removing its stale version
reference. Fixes #11539. |
| 5 | [#11725](#11725) Fix
batch activity unpause visibility query scope | @fretz12 | The server
replaced the caller's visibility query with the activity-type predicate,
which could broaden the batch scope and unpause activities in workflows
the caller never selected. |
| 6 | [#11806](#11806) Fix
activity operator command metric label collision | @fretz12 | WFA and
SAA emitted the same Prometheus metric names
(`activity_pause`/`unpause`/`reset`/`update_options`) with **different
label sets**, causing descriptor registration failures and dropped
metrics. Both now use the standard per-activity label schema and emit
once per affected activity. **See "Backport adaptation" below.** |
| 7 | [#11930](#11930)
Prioritize worker versioning workflows | @ShahabT | Worker versioning
workflows share the per-namespace worker task queue with other system
workflows. Raising their initial workflow-task priority above default
keeps versioning operations from queueing behind default-priority work.
|
| 8 | [#11910](#11910)
[Visibility] Fix legacy visibility query converter | @rodrigozhou |
Fixes to the legacy visibility query converter for both SQL and
Elasticsearch. |
| 9 | [#11699](#11699)
dynamic partitioning: use probability of AddTask to root partition to
estimate overall add task rate | @carlydf | A previous PR changed
AddTask load-balancing from uniform random to backlog-aware,
invalidating the uniform-distribution assumption behind the
add-task-rate estimate. Now estimates from the probability of AddTask
hitting the root partition, and guarantees the root retains at least a
1% chance of selection regardless of its backlog. |
| 10 | [#11935](#11935)
[Visibility] Enable unified query converter by default | @rodrigozhou |
Flips the default now that the unified query converter is stable and
ready to replace the old one. Depends on #11910 and #11801. |

## How did you test it?

- [x] built — `go build ./...`
- [x] `make fmt` — no changes
- [x] `go vet -tags disable_grpc_modules,test_dep ./tests/...` — clean
- [x] `make GOLANGCI_LINT_FIX=false
GOLANGCI_LINT_BASE_REV=origin/release/v1.32.x lint-code` — **0 issues**
- [x] covered by existing tests — 21 affected packages, **20 pass**

---------

Co-authored-by: Sean Kane <[email protected]>
Co-authored-by: Fred Tzeng <[email protected]>
Co-authored-by: Kannan <[email protected]>
Co-authored-by: Shahab Tajik <[email protected]>
Co-authored-by: Rodrigo Zhou <[email protected]>
Co-authored-by: Carly de Frondeville <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vladyslav Simonenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/1.32.0 reliability-2026 Reliability related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants