Skip to content

fix(insight): keep one pending export slot per execution - #716

Open
wangyb-A wants to merge 1 commit into
mainfrom
workflow-insight-per-execution-pending
Open

wangyb-A wants to merge 1 commit into
mainfrom
workflow-insight-per-execution-pending

Conversation

@wangyb-A

Copy link
Copy Markdown
Contributor

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Issue Link, if available

Addresses the item reported in #679 (comment) (part of #679; the issue stays open for the remaining follow-ups).

Description

ExportScheduler held one pending slot and let any newer record replace the one waiting. That rule is only valid for records of the same execution. A snapshot of execution B carries none of execution A's information, so when records of two executions interleaved, A's pending record was discarded and nothing else would deliver it. At invocation end this dropped A's terminal record while A's end hook was already waiting in drain().

The pending slot is now a map keyed by execution ARN in insertion order. A newer record still supersedes an older one of the same execution. Records of different executions never displace each other. Executions are served in the order they first became pending, and a re-scheduled execution keeps its place, so a chatty execution cannot starve a quieter one. Exactly one export stays in flight at a time, so the exporter contract is unchanged.

Memory stays bounded at one record per concurrently active execution, and every pump drains the map to empty.

Demo/Screenshots

N/A. Behavior is covered by unit tests.

Checklist

  • I have filled out every section of the PR template
  • I have thoroughly tested this change

Testing

Unit Tests

Yes. Three new ExportSchedulerTest cases: records of different executions never displace each other; coalescing stays within one execution and executions are served in first-pending order; another execution's update while an export is in flight cannot drop a pending final record. One new WorkflowInsightHookTest case reproduces the reported sequence end to end: execution A's end hook waits in the drain behind a blocked export while execution B's change hook arrives, and both executions' SUCCEEDED records are delivered.

All four tests were run against the previous scheduler and fail there with the reported symptom (A delivers only RUNNING). mvn clean verify passes across all modules; the two concurrency-sensitive test classes were repeated 10 times with no failures.

Integration Tests

No new integration tests; the existing LocalDurableTestRunner-based plugin tests still pass.

Examples

N/A. No public API change.

The scheduler held a single pending slot and let any newer record replace
the one waiting. That is only valid for records of the same execution: a
snapshot of execution B carries none of execution A's information, so when
records of two executions interleaved, A's pending record was discarded and
nothing else would deliver it. At invocation end this dropped A's terminal
record while A's end hook was already waiting in drain().

Pending records are now keyed by execution ARN in insertion order. A newer
record still supersedes an older one of the same execution, records of
different executions never displace each other, and executions are served
in the order they first became pending. Exactly one export remains in
flight at a time.
@wangyb-A

Copy link
Copy Markdown
Contributor Author

/ai review

@github-actions

This comment has been minimized.

@wangyb-A
wangyb-A marked this pull request as ready for review September 15, 2026 01:07
@wangyb-A
wangyb-A requested a review from a team September 15, 2026 01:07
@wangyb-A
wangyb-A deployed to ai-pr-review-runtime September 15, 2026 01:07 — with GitHub Actions Active
@wangyb-A
wangyb-A deployed to ai-pr-review-runtime September 15, 2026 01:10 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

No actionable findings. Residual risk is limited to concurrency timing because tests were not executed under the review constraints.

Reviewed commit 96c86631862d841e0d05b33ccd85a57ac4f2468a. Workflow run

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.

1 participant