Skip to content

Conversation

@simvlad
Copy link
Contributor

@simvlad simvlad commented Dec 8, 2025

What changed?

Keep the total number and the size of the external payloads per the workflow execution

Why?

We are working on building the support for external payloads in SDK, which are stored outside of Temporal. We'd like to be able to show the total size and the number of external payloads in the given workflow execution.

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

N/A

@yycptt
Copy link
Member

yycptt commented Dec 12, 2025

I think state-based replication logic in workflow_state_replicator.go also changes HistorySize and needs to be updated as well. Haven't finished the review yet, will continue tomorrow.

cc @xwduan @yux0 Please help review this PR as most of the changes are actually on the replication side.

@yycptt yycptt requested review from xwduan and yux0 December 15, 2025 06:48
@simvlad simvlad force-pushed the simvlad/payload-size-stats-for-workflow-execution branch from 9390400 to c7d356a Compare December 15, 2025 21:03
@simvlad
Copy link
Contributor Author

simvlad commented Dec 16, 2025

@xwduan, @yux0 - I fixed the replication logic in service/history/ndc/workflow_state_replicator.go and added the test to service/history/ndc/workflow_state_replicator_test.go. Please take a look when you have time.

@simvlad simvlad force-pushed the simvlad/payload-size-stats-for-workflow-execution branch 2 times, most recently from c6237a3 to dc31bb8 Compare December 18, 2025 21:41
@simvlad simvlad force-pushed the simvlad/payload-size-stats-for-workflow-execution branch from dc31bb8 to ac1098d Compare January 2, 2026 19:18
paginateItems = append(paginateItems, nextBatch)

// Calculate and accumulate external payload size and count for this batch of history events
if r.shard.GetConfig().ExternalPayloadsEnabled(namespaceName) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: feel like checking the flag once per page/request is also good enough. no strong opinion.

@yycptt
Copy link
Member

yycptt commented Jan 2, 2026

@yux0 @xwduan plz take a look as well. Thanks!

ms.executionInfo.LastFirstEventTxnId = historyNodeTxnIDs[index]

// Calculate and add the external payload size and count for this batch
if ms.config.ExternalPayloadsEnabled(ms.GetNamespaceEntry().Name().String()) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should reset the size & count if the feature flag is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can exclude it from the results of DescribeWorkflowExecution, but not sure if resetting would make this better. We still need to explicitly retrigger the recomputation of it, if it somehow gets computed incorrectly.

Copy link
Member

Choose a reason for hiding this comment

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

We still need to explicitly retrigger the recomputation of it

How do we know if recomputation is needed for an execution if the feature flag get disabled and then enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But having those fields set tot 0, is also not a good indicator that the recomputation is necessary.

@simvlad simvlad force-pushed the simvlad/payload-size-stats-for-workflow-execution branch from 93fe315 to 2f2c759 Compare January 2, 2026 23:44
@simvlad simvlad force-pushed the simvlad/payload-size-stats-for-workflow-execution branch from 2f2c759 to b67ab26 Compare January 3, 2026 03:24
@simvlad
Copy link
Contributor Author

simvlad commented Jan 5, 2026

This feature is gated/in pre-release, so I'll merge this change. But @xwduan, @yux0, let me know if there are any changes needed to the replication part.

@simvlad simvlad merged commit f6af2b3 into main Jan 5, 2026
59 checks passed
@simvlad simvlad deleted the simvlad/payload-size-stats-for-workflow-execution branch January 5, 2026 18:36
simvlad added a commit that referenced this pull request Jan 5, 2026
## What changed?
Added external payload stats (size and count) to
DescribeWorkflowExecution. Also change and add functional tests. **This
PR depends on Server PR #8775
and API PR temporalio/api#689

## Why?
We'd like to surface the external payload stats when
DescribeWorkflowExecution is called to see how many and what size of
external payloads the workflow is referencing. Numbers are coming from
the workflow mutable state. This is similar to how the HistorySize is
kept.

## How did you test it?
- [X] built
- [ ] run locally and tested manually
- [X] covered by existing tests
- [X] added new unit test(s)
- [X] added new functional test(s)
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