Repository navigation
UN-4514 [FIX] Cut per-document workflow-execution fetches and stop loading every file-execution row on each one - #2377
muhammad-ali-e wants to merge 3 commits into
Conversation
… executions by default Workers fetched the workflow-execution context about 8 times per document, and every fetch loaded all of the execution's file-execution rows: the backend defaults file_execution to true and the client only ever sent "?file_execution=true", never false. - Client always sends file_execution explicitly, defaults to false, and builds the query via params (include_cost + file_execution used to produce "?include_cost=true?file_execution=true"). - Callbacks still request the rows (subscription billing reads them) and hand the fetched context to the status step, which reused to make two more GETs (wall-clock time, expected files). - Each file reuses the batch's execution context instead of fetching it, and its source/destination config lookups reuse it too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WpxxVeu41XtPNkvP2Lm8H4
for more information, see https://pre-commit.ci
[Medium impact] The PR appears safe to merge; no actionable new issue was found.
|
|
|
…che, harden fallbacks - Drop reusing the batch's execution context per file: it would freeze the source connector settings (auth tokens) for the whole batch. Each file fetches once (no file-execution rows); its config lookups reuse that. - Key the per-file cache by execution_id. - Status step tolerates a missing context; wall-clock time refetches on an empty one. - Name the full response execution_context throughout. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WpxxVeu41XtPNkvP2Lm8H4
|
Self-review before asking for a human review. I ran three review rounds; this is what changed in 5cdd74a and what I deliberately left out. Fixed
Not changed, with reasons
Generated by Claude Code |
|
Unstract test resultsPer-group results
Critical paths
|



Requested by ali · project thread
What
get_workflow_execution(worker client) now always sendsfile_executionexplicitly, defaults it tofalse, and builds its query throughparams.Why
Load tests showed ~29 internal API calls per document, 8 of them
GET workflow-execution/<id>/, at 0.5–1.5 s each under load. Every one of them also ranlist(execution.file_executions.values()):file_executiontotrue;?file_execution=trueand never sentfalse, so every caller passingfile_execution=Falsestill got all rows.For an ETL run with N files, the per-file fetches made that O(N²) rows. Separately,
include_cost=Truewith the old default produced?include_cost=true?file_execution=true, which the backend parsed asinclude_cost="true?file_execution=true", so no cost was returned. Current callers happen to avoid it.How
Per document (API deployment, one file), GETs before → after:
include_cost)ETL saves 1 GET per file, and none of the per-file or per-batch fetches scale with the file count any more.
shared/clients/execution_client.py:params={"file_execution": "true"|"false", ["include_cost": "true"]}; defaultFalse(also in theInternalAPIClientfacade).callback/tasks.py:_extract_callback_parametersandprocess_batch_callback_apirequestfile_execution=True, which matches what they actually received before. The context is stored asCallbackContext.execution_contextand passed to_determine_execution_status_unified(execution_context=...).shared/processing/files/time_utils.py:calculate_execution_time(..., execution_context=None)reuses the context when given (created_atis immutable;nowis still taken at call time) and refetches if it is empty.shared/workflow/execution/service.py: the file's context is kept, keyed byexecution_id, for_get_source_config/_get_destination_config.The context is deliberately not shared from the batch to each file. The file's source connector settings (including auth tokens) come from this fetch, so sharing it would freeze them for the whole batch, which can run for an hour.
Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
context.file_executions. Both callback fetches now ask for the rows explicitly, so billing gets the same data as before. A test covers this.true, so older workers behave exactly as before. New workers simply say what they want.expected_filesis still read from the top level of the response, as before. That key doesn't exist there (it lives underexecution), soexpected_filesis always 0 today, on main too. I left it alone because fixing it would change the timeout-failure behaviour; it's noted on UN-4514 for a separate change.callback/readsfile_executionsfrom this endpoint (checked in OSS and unstract-cloud).Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
workers/tests/test_workflow_execution_fetch_reuse.py(17 tests): query params, callback fetch/reuse, wall-clock reuse and fallbacks, per-file fetch-once, and cache keying.workflow-executionGETs.🤖 Generated with Claude Code
https://claude.ai/code/session_01WpxxVeu41XtPNkvP2Lm8H4