Repository navigation
fix: scope large binary storage and cleanup by execution id - #5280
Conversation
Also update existing call site in RegionExecutionCoordinator to pass None for the new field (required because ScalaPB no_default_values_in_constructor is true).
…he#4123) betterproto returns an empty (falsy) ExecutionIdentity for an unset executionId field rather than None, so the previous `is not None` check never triggered and an unset id would silently produce objects/0/... Use truthiness so unset -> None -> create() raises, matching the JVM invariant. Also moves a stray mid-file `import re` to the top.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5280 +/- ##
============================================
+ Coverage 51.99% 52.02% +0.03%
+ Complexity 2472 2471 -1
============================================
Files 1067 1067
Lines 41258 41291 +33
Branches 4437 4438 +1
============================================
+ Hits 21452 21483 +31
+ Misses 18550 18547 -3
- Partials 1256 1261 +5
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6a0709e to
94c2804
Compare
…apache#4123) Move the per-execution id out of StorageConfig (which holds only static system configuration sourced from storage.conf) into a dedicated module-level holder in large_binary_manager (set_current_execution_id), mirroring the JVM LargeBinaryManager. The Python init handler sets it via that API.
Add get_current_execution_id() and route create() and the tests through it instead of reading the module-level _current_execution_id directly, keeping the holder's access encapsulated.
|
/request-review @Xiao-zhen-Liu Can you review this PR because you are an engine expert? |
|
@Xiao-zhen-Liu Please review the PR as requested. |
apache#4123) Address review feedback: replace the module-level globals (_s3_client, DEFAULT_BUCKET, _current_execution_id) and free functions with a LargeBinaryManager class holding state as instance attributes, exposed as a single shared per-worker singleton. No more `global` statements; mirrors the JVM `object LargeBinaryManager`. Consumers import the singleton, so call sites are unchanged. Update the stream/type tests to patch the singleton instance.
…pache#4123) The pure create() logic (execution-scoped key + fail-fast when no context is set) was only exercised by the MinIO-backed LargeBinaryManagerSpec. Move those two assertions into LargeBinaryManagerUnitSpec so they run without Docker and count toward coverage; the MinIO spec keeps the isolation test that genuinely needs a live S3 endpoint. deleteByExecution's success and swallow branches were already covered by the unit spec.
Xiao-zhen-Liu
left a comment
There was a problem hiding this comment.
Thanks for this — the core fix is right, and replacing the global "delete everything" with per-execution deletion is a clear improvement over a genuinely dangerous behavior. Tests are solid; the cross-execution isolation test and the new MinIO-free unit test are exactly what this change needed.
My main feedback is one design question, left inline on the new proto field. Briefly: large binaries are currently the only execution-scoped resource that the worker names itself, which is the whole reason the execution id now has to be pushed down to workers (the new proto field, the handler change, and the per-engine execution-id state). Every other resource — results, state, console messages — is named by the controller with the execution id already in the address, then handed to the worker as data. Making large binaries follow that same pattern would remove the need for the worker to know the execution id at all. It's a bigger change than this PR, so it's your call whether to do it here or as a follow-up — what's here works fine for now.
Two things I'd fix before merge regardless of that decision:
- Large binaries are deleted before the workflow-delete transaction commits, so a rollback leaves binaries gone but rows intact (
WorkflowResource). Move the deletion after the transaction, next to the existing document cleanup. - The cleanup path swallows all errors with a WARN, so a misconfigured endpoint silently leaks storage. Confirm that's intentional and at least log it at
error.
The rest are small consistency and readability notes inline (the JVM/Python handlers disagree when the id is missing; the "mirrors the JVM" comment could explain why the two differ; the duplicated bucket name). On the plus side, WorkflowService.clearExecutionResources is the call site this bug hurt most and it's correctly scoped now. Nice work overall.
581bc74 to
a12bc7c
Compare
- WorkflowResource: delete large binaries after the DB transaction so a rollback does not leave workflow rows intact with their binaries gone - deleteByExecution: log failures at error and document the intentional swallow - align the JVM and Python workers on a missing execution id: JVM setCurrentExecutionId now takes Option and always overwrites (None clears), matching Python, so a missing id fails loudly rather than reusing a stale one - document the data-processing-thread requirement; note the JVM and Python managers hold the id differently (thread-local vs process singleton) - Python create(): validate the execution id before any S3 round-trip - source the large-binaries bucket from config (StorageConfig) in both engines so they cannot drift; guard create() against an unset bucket; keep the worker-launch positional arg contract in sync on both sides - tests: reset state in finally, pass a real ExecutionIdentity in WorkerSpec, use the public setter
…pache#4123) Per review, mark the field no_box so the "missing id" case cannot arise. Drop the Some(...) wrapper at the controller and have both worker handlers read executionId.id directly; revert the Option-based setter workaround. This makes the JVM and Python workers handle the field identically.
…roto field Large binaries were the only execution-scoped resource the worker named itself, which is why scoping their S3 keys by execution id previously required pushing the execution id down to workers via a new InitializeExecutorRequest.executionId proto field. Instead, name the location in the controller and hand it down as data, the way other execution-scoped resources already are: - The controller computes the execution-scoped base URI (s3://<bucket>/objects/<eid>/) via LargeBinaryManager.baseUriForExecution and puts it on WorkerConfig, a plain config object already delivered to both engines and serialized across remote deploys. - JVM: WorkerConfig -> DPThread, which seeds it onto the data-processing thread at startup. Python: WorkerConfig -> sys.argv -> StorageConfig. create() just appends a UUID. - Drop the InitializeExecutorRequest.executionId proto field and the per-engine executor-init handler changes, so the .proto is unchanged from main and no proto regeneration is required. Review-driven cleanups: - Centralize the per-execution key layout in LargeBinaryManager.executionPrefix so the write and delete paths cannot drift. - Make setCurrentBaseUri take a String (empty == unset) so production and tests seed the thread-local identically. - Document the one-worker-per-execution assumption the seeding relies on.
- Make the Python LargeBinaryManager singleton thread-safe (lock plus double-checked locking in __new__ and _get_s3_client); it is reached from both the operator thread and LargeBinaryOutputStream's upload thread. - Add a regression test that deleteByExecution distinguishes executions whose ids share a numeric prefix (e.g. 1 vs 11), pinning the trailing-slash normalization in S3StorageClient.deleteDirectory. - Document that baseUriForExecution requires a persisted execution id; the default sentinel id (DEFAULT_EXECUTION_ID = 1) shares the numeric space. - Note the single-page (up to 1000 objects) bound of deleteByExecution. - Reword the misleading "one worker per execution" comments to "one execution per worker / DP thread" (an execution's parallel workers are fine). - Rename the stale "delete all objects" Scala tests to reflect the per-execution scope.
Condense the verbose doc blocks and inline comments in this area while keeping the key rationale: thread-local base-URI seeding, the executionId = 1 sentinel overlap, the deleteDirectory single-page bound, and the swallow-and-log reason. No code or behavior change.
|
@Xiao-zhen-Liu I made a lot of changes in this PR. The changes are mainly,
Can you have one more pass on this PR? |
|
@kunwp1 this PR changed 23 files. Can you make it into smaller PRs? |
|
@Xiao-zhen-Liu Do you want me to split this PR? |
Xiao-zhen-Liu
left a comment
There was a problem hiding this comment.
LGTM now. All my earlier comments are addressed — the main one properly: the controller builds the execution-scoped base URI and passes it to the worker through WorkerConfig, so the proto field and the worker-side execution id are both gone. Smaller items are in too (delete moved after the transaction, error-level logging, bucket from StorageConfig, clearer docs, tests reset their state). Left two non-blocking follow-ups inline plus two minor notes.
|
@kunwp1 No need to split. It's 23 files but one self-contained fix (scope large-binary storage and cleanup by execution id). The count is high because the JVM and Python sides each do the same thing with their own tests, plus some import changes from the Python refactor — not 23 separate changes. The parts also can't be merged on their own: naming the URI on the controller, reading it on the worker, and scoping create/delete only work together. Splitting them would leave @chenlica I'd keep it as one PR for that reason. Genuinely separable work — like the >1000-object delete I noted below — can go in its own follow-up. |
- DPThreadSpec: a DPThread built with a base URI seeds it on the DP thread, so create() there yields execution-scoped keys. - SchedulingConfigsSpec: generateWorkerConfigs sets largeBinaryBaseUri to baseUriForExecution(eid) for every worker. Locks the controller->WorkerConfig and DPThread-seeding links against future refactors (addresses review feedback).
Signed-off-by: Kunwoo (Chris) <[email protected]>
|
@Xiao-zhen-Liu Thanks for the review! 🙌 I've applied all the fixes. If everything looks good now, I'll merge this tonight! |
…release/v1.2 backport] (#5602) ### What changes were proposed in this PR? Backport of #5280 ("scope large binary storage and cleanup by execution id") to `release/v1.2`. As noted in #5569, #5280 cannot be backported as a single cherry-pick: its changes to `large_binary_output_stream.py` build on top of #5249 ("keep failed-upload cleanup inside the upload worker"), which is not present on `release/v1.2`. Cherry-picking #5280 alone leaves a dangling reference to the `large_binary_manager` module in `_cleanup_failed_upload()` (a method #5249 removes), producing a `NameError` at runtime. This PR therefore backports the dependency chain, both as clean `git cherry-pick -x` of the original squash commits: 1. **#5249** — keep failed-upload cleanup inside the upload worker (prerequisite) 2. **#5280** — scope large binary storage and cleanup by execution id `#4707` (which #5249 follows up on) is already present on `release/v1.2`, so the chain stops there. After applying both commits, every file touched by #5280 is byte-identical to its state on `main` at the merged #5280 commit (`48e800e4`), and `release/v1.2` had no independent changes to any of those files. ### Any related issues, documentation, discussions? Backports #5280 (which closes #4123 on `main`). Prerequisite: #5249. Unblocks the #5569 backport, which can then cherry-pick cleanly onto `release/v1.2`. ### How was this PR tested? This is a backport with no changes beyond the two cherry-picked commits, so it relies on the existing tests carried over from #5249 and #5280 (`LargeBinaryManagerSpec`, `LargeBinaryManagerUnitSpec`, `test_large_binary_output_stream.py`, `test_large_binary_manager.py`, etc.). Backport fidelity was verified locally by confirming that, after the chain is applied onto `release/v1.2`: - all files touched by #5280 are byte-identical to `main@48e800e`; - no callers of the removed `deleteAllObjects()` remain; - `deleteByExecution` is wired in `WorkflowResource` and `WorkflowService`. Full compile and unit-test runs are left to CI. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) --------- Signed-off-by: Matthew B. <[email protected]> Signed-off-by: Kunwoo (Chris) <[email protected]> Co-authored-by: Matthew B. <[email protected]> Co-authored-by: Xiaozhen Liu <[email protected]>
…rd (#5565) [release/v1.2 backport] (#5609) ### What changes were proposed in this PR? Backport of #5565 ("fix(frontend): clean up websocket state when returning to the dashboard") to `release/v1.2`. Applies as a clean `git cherry-pick -x` of the merged squash commit `ad10b7f2b` — no conflicts and no prerequisite chain (unlike the #5280 backport in #5602). Frontend-only: 14 files changed, 391 insertions, 2 deletions, identical to the original. For the full change description see #5565. In brief: websocket-derived front-end state (the connection, plus execution status, console output, and results built from its events) lives in singletons outside the workspace and was never torn down when returning to the dashboard or switching computing units, so stale state carried over. This tears that state down in `WorkspaceComponent.ngOnDestroy()` and clears it again on a computing-unit switch. ### Any related issues, documentation, discussions? Backports #5565 (which closes #3120 on `main`). Related: #3093. ### How was this PR tested? This is a backport with no changes beyond the single cherry-picked commit, so it relies on the existing tests carried over from #5565 (added `*.spec.ts` cases across `computing-unit-status`, `workspace.component`, `execute-workflow`, `workflow-console`, `workflow-result`, `result-panel`, and `workflow-websocket`). Backport fidelity was verified locally: after the cherry-pick, every file touched by #5565 is byte-identical to its state on `main` at the merged commit (`ad10b7f2b`), and `release/v1.2` had no independent changes to any of those files. Full compile and unit-test runs are left to CI. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) Co-authored-by: Xinyuan Lin <[email protected]>
) ### What changes were proposed in this PR? Large binaries were stored in the shared `texera-large-binaries` bucket under flat keys `objects/{timestamp}/{uuid}` with no execution id, and `clearExecutionResources(eid)` deleted all of them via `LargeBinaryManager.deleteAllObjects()`. Any cleanup for one execution therefore erased every other execution's (and user's) large binaries. This PR namespaces every large binary by its execution id and scopes deletion: - Object keys are now `objects/{eid}/{uuid}` on both the JVM and Python workers. - The execution-scoped location is named by the controller and handed to workers as data on `WorkerConfig` — no protobuf change. The controller computes the base URI `s3://{bucket}/objects/{eid}/`, and `create()` appends a unique suffix; the JVM seeds the base URI onto the data-processing thread at startup, and the Python worker receives it as a startup argument. The user-facing `largebinary()` / `new LargeBinary()` APIs are unchanged. - Cleanup uses the new `LargeBinaryManager.deleteByExecution(eid)` (prefix delete of `objects/{eid}/`). Both JVM and Python engines share the bucket and key shape, so this single JVM-side delete removes binaries created by both. - The `deleteAllObjects()` is removed. Pre-existing objects under the old `objects/{timestamp}/...` scheme are left untouched. ### Any related issues, documentation, discussions? Closes apache#4123. ### How was this PR tested? Import the following json file to create two workflows (You can configure the source operator to use any kinds of files you have), run them, and check if each execution creates 6 objects and one execution doesn't remove the other execution's large binary objects. [Large.Binary.Python (1).json](https://github.com/user-attachments/files/28369502/Large.Binary.Python.1.json) ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Anthropic), models Claude Opus 4.8, Claude Opus 4.7, and Claude Sonnet 4.6 --------- Signed-off-by: Kunwoo (Chris) <[email protected]> Co-authored-by: Xiaozhen Liu <[email protected]>
) ### What changes were proposed in this PR? Large binaries were stored in the shared `texera-large-binaries` bucket under flat keys `objects/{timestamp}/{uuid}` with no execution id, and `clearExecutionResources(eid)` deleted all of them via `LargeBinaryManager.deleteAllObjects()`. Any cleanup for one execution therefore erased every other execution's (and user's) large binaries. This PR namespaces every large binary by its execution id and scopes deletion: - Object keys are now `objects/{eid}/{uuid}` on both the JVM and Python workers. - The execution-scoped location is named by the controller and handed to workers as data on `WorkerConfig` — no protobuf change. The controller computes the base URI `s3://{bucket}/objects/{eid}/`, and `create()` appends a unique suffix; the JVM seeds the base URI onto the data-processing thread at startup, and the Python worker receives it as a startup argument. The user-facing `largebinary()` / `new LargeBinary()` APIs are unchanged. - Cleanup uses the new `LargeBinaryManager.deleteByExecution(eid)` (prefix delete of `objects/{eid}/`). Both JVM and Python engines share the bucket and key shape, so this single JVM-side delete removes binaries created by both. - The `deleteAllObjects()` is removed. Pre-existing objects under the old `objects/{timestamp}/...` scheme are left untouched. ### Any related issues, documentation, discussions? Closes apache#4123. ### How was this PR tested? Import the following json file to create two workflows (You can configure the source operator to use any kinds of files you have), run them, and check if each execution creates 6 objects and one execution doesn't remove the other execution's large binary objects. [Large.Binary.Python (1).json](https://github.com/user-attachments/files/28369502/Large.Binary.Python.1.json) ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Anthropic), models Claude Opus 4.8, Claude Opus 4.7, and Claude Sonnet 4.6 --------- Signed-off-by: Kunwoo (Chris) <[email protected]> Co-authored-by: Xiaozhen Liu <[email protected]>
What changes were proposed in this PR?
Large binaries were stored in the shared
texera-large-binariesbucket under flat keysobjects/{timestamp}/{uuid}with no execution id, andclearExecutionResources(eid)deleted all of them viaLargeBinaryManager.deleteAllObjects(). Any cleanup for one execution therefore erased every other execution's (and user's) large binaries.This PR namespaces every large binary by its execution id and scopes deletion:
objects/{eid}/{uuid}on both the JVM and Python workers.WorkerConfig— no protobuf change. The controller computes the base URIs3://{bucket}/objects/{eid}/, andcreate()appends a unique suffix; the JVM seeds the base URI onto the data-processing thread at startup, and the Python worker receives it as a startup argument. The user-facinglargebinary()/new LargeBinary()APIs are unchanged.LargeBinaryManager.deleteByExecution(eid)(prefix delete ofobjects/{eid}/). Both JVM and Python engines share the bucket and key shape, so this single JVM-side delete removes binaries created by both.deleteAllObjects()is removed.Pre-existing objects under the old
objects/{timestamp}/...scheme are left untouched.Any related issues, documentation, discussions?
Closes #4123.
How was this PR tested?
Import the following json file to create two workflows (You can configure the source operator to use any kinds of files you have), run them, and check if each execution creates 6 objects and one execution doesn't remove the other execution's large binary objects.
Large.Binary.Python (1).json
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Anthropic), models Claude Opus 4.8, Claude Opus 4.7, and Claude Sonnet 4.6