-
Notifications
You must be signed in to change notification settings - Fork 189
feat(scheduling): reuse output storage across region re-executions #5707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aglinxinyuan
merged 15 commits into
apache:main
from
aglinxinyuan:loop-reuse-output-storage
Jun 17, 2026
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
bcaed05
feat(scheduling): reuse output storage across region re-executions
aglinxinyuan e89684e
Merge branch 'main' into loop-reuse-output-storage
aglinxinyuan 8f734ec
test(workflow-core): cover withReusesOutputStorageOnReExecution builder
aglinxinyuan def4ce8
Merge branch 'main' into loop-reuse-output-storage
aglinxinyuan 45fc475
refactor(scheduling): move reuse decision to storage layer, flag to O…
aglinxinyuan a2e9006
Merge branch 'main' into loop-reuse-output-storage
aglinxinyuan 3933fad
style(scheduling): drop now-unused java.net.URI import
aglinxinyuan 6f85e6b
test(workflow-operator): guard that no operator enables reusesOutputS…
aglinxinyuan 9136316
Merge branch 'main' into loop-reuse-output-storage
aglinxinyuan 5690bd5
refactor(storage): createOrReuseDocument returns the document + guard…
aglinxinyuan 847d2da
Merge branch 'main' into loop-reuse-output-storage
aglinxinyuan 01875a0
Merge branch 'main' into loop-reuse-output-storage
aglinxinyuan 7897ae6
refactor(scheduling): rename OutputPort flag to reuseStorage; tidy co…
aglinxinyuan 495d2f9
Merge branch 'main' into loop-reuse-output-storage
aglinxinyuan fe81369
Merge branch 'main' into loop-reuse-output-storage
aglinxinyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
...org/apache/texera/amber/engine/architecture/scheduling/RegionOutputProvisioningSpec.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.texera.amber.engine.architecture.scheduling | ||
|
|
||
| import org.scalatest.flatspec.AnyFlatSpec | ||
| import org.scalatest.matchers.should.Matchers | ||
|
|
||
| import java.net.URI | ||
| import scala.collection.mutable | ||
|
|
||
| /** | ||
| * Unit tests for `RegionExecutionCoordinator.provisionOutputDocument`, the | ||
| * create-or-reuse decision behind output-port storage provisioning. | ||
| * | ||
| * This is the branch that lets a re-executing region (a loop body) keep the | ||
| * output an earlier run accumulated instead of clobbering it: a LoopEnd's | ||
| * region runs once per iteration, and `DocumentFactory.createDocument` | ||
| * overrides any existing document, so on a re-run we must reuse the existing | ||
| * document rather than recreate it. | ||
| * | ||
| * The decision was pulled out of the private `createOutputPortStorageObjects` | ||
| * (which needs a live controller + iceberg backend) into a pure function with | ||
| * injected `documentExists` / `createDocument`, so the four cases can be | ||
| * pinned directly with a spy -- no iceberg, no actor system. | ||
| */ | ||
| class RegionOutputProvisioningSpec extends AnyFlatSpec with Matchers { | ||
|
|
||
| private val uri = new URI("vfs:///wf/result/loop-end") | ||
|
|
||
| /** Run provisionOutputDocument and return (created?, number of create calls). */ | ||
| private def provision( | ||
| reuseExistingStorage: Boolean, | ||
| exists: Boolean | ||
| ): (Boolean, Int) = { | ||
| val createCalls = mutable.ArrayBuffer.empty[URI] | ||
| val created = RegionExecutionCoordinator.provisionOutputDocument( | ||
| uri, | ||
| reuseExistingStorage, | ||
| _ => exists, | ||
| u => { createCalls += u; () } | ||
| ) | ||
| (created, createCalls.size) | ||
| } | ||
|
|
||
| "provisionOutputDocument" should | ||
| "reuse (not recreate) an existing document when the operator reuses storage" in { | ||
| // The loop-iteration case: the document is already there from a prior | ||
| // region run, so createDocument must NOT be called -- otherwise the | ||
| // accumulated output would be clobbered. | ||
| val (created, createCalls) = provision(reuseExistingStorage = true, exists = true) | ||
| created shouldBe false | ||
| createCalls shouldBe 0 | ||
| } | ||
|
|
||
| it should "create the document when the operator reuses storage but none exists yet" in { | ||
| // First iteration: nothing to reuse, so it must be created. | ||
| val (created, createCalls) = provision(reuseExistingStorage = true, exists = false) | ||
| created shouldBe true | ||
| createCalls shouldBe 1 | ||
| } | ||
|
|
||
| it should "always (re)create when the operator does not reuse storage, even if a document exists" in { | ||
| // Non-loop operators get a fresh document every region execution; an | ||
| // existing one is intentionally overwritten. | ||
| val (created, createCalls) = provision(reuseExistingStorage = false, exists = true) | ||
| created shouldBe true | ||
| createCalls shouldBe 1 | ||
| } | ||
|
|
||
| it should "create when the operator does not reuse storage and none exists" in { | ||
| val (created, createCalls) = provision(reuseExistingStorage = false, exists = false) | ||
| created shouldBe true | ||
| createCalls shouldBe 1 | ||
| } | ||
|
|
||
| it should "not call documentExists when the operator does not reuse storage (create unconditionally)" in { | ||
| // Short-circuit: a non-reuse operator always recreates, so it must not | ||
| // even probe for existence. | ||
| var existsProbed = false | ||
| RegionExecutionCoordinator.provisionOutputDocument( | ||
| uri, | ||
| reuseExistingStorage = false, | ||
| _ => { existsProbed = true; true }, | ||
| _ => () | ||
| ) | ||
| existsProbed shouldBe false | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.