Skip to content

fix: ensure execution plan initialized after target setup (#49)#92

Merged
bashandbone merged 1 commit intomainfrom
claude/issue-49-20260310-2124
Mar 13, 2026
Merged

fix: ensure execution plan initialized after target setup (#49)#92
bashandbone merged 1 commit intomainfrom
claude/issue-49-20260310-2124

Conversation

@bashandbone
Copy link
Copy Markdown
Contributor

Adopt upstream bug fix from cocoindex-io/cocoindex#1715 (commit ba2fc4a).

The bug allowed the execution plan to be initialized before target setup was complete in certain cases. This race could cause the planner to use outdated or incomplete state, leading to subtle bugs when resources are quickly provisioned or flows reconfigured.

Changes:

  • Add Debug and Clone derives to ExportOpExecutionContext
  • Refactor TrackingTableSetupChange to store lazy execution plan
  • Pass execution_plan and export_op_execution_contexts to diff_flow_setup_states
  • Move tracking table setup to occur AFTER all target setup completes

This ensures tracking table initialization only happens after all target contexts exist, preventing race conditions in flow setup.

Closes #49

Adopt upstream bug fix from cocoindex-io/cocoindex#1715 (commit ba2fc4a).

The bug allowed the execution plan to be initialized before target setup
was complete in certain cases. This race could cause the planner to use
outdated or incomplete state, leading to subtle bugs when resources are
quickly provisioned or flows reconfigured.

Changes:
- Add Debug and Clone derives to ExportOpExecutionContext
- Refactor TrackingTableSetupChange to store lazy execution plan
- Pass execution_plan and export_op_execution_contexts to diff_flow_setup_states
- Move tracking table setup to occur AFTER all target setup completes

This ensures tracking table initialization only happens after all target
contexts exist, preventing race conditions in flow setup.

Co-authored-by: Adam Poulemanos <bashandbone@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 13, 2026 20:16
@bashandbone bashandbone added bug Something isn't working upstream-sync Issues for syncing updates with our upstream (cocoindex-io/cocoindex) labels Mar 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🤖 Hi @bashandbone, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adopts an upstream fix to prevent flow setup from initializing/using an execution plan before target setup is complete, by deferring tracking-table setup and threading plan/context data needed for lazy resolution.

Changes:

  • Reorder flow setup application so tracking table setup runs after all target setup completes.
  • Extend flow diffing to accept a shared/lazy execution plan and export-op execution contexts.
  • Add Debug/Clone derives and refactor tracking table setup change to carry the lazy plan/context.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
crates/recoco-core/src/setup/driver.rs Adds execution-plan/context params to flow diffing and applies tracking table setup after targets.
crates/recoco-core/src/lib_context.rs Passes execution plan + export contexts into flow diffing during setup context build.
crates/recoco-core/src/execution/db_tracking_setup.rs Refactors TrackingTableSetupChange to store a lazy execution plan and export contexts; custom Debug.
crates/recoco-core/src/builder/exec_ctx.rs Derives Debug and Clone for ExportOpExecutionContext to enable cloning at call sites.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 352 to 363
pub async fn diff_flow_setup_states(
desired_state: Option<&FlowSetupState<DesiredMode>>,
existing_state: Option<&FlowSetupState<ExistingMode>>,
flow_instance_ctx: &Arc<FlowInstanceContext>,
execution_plan: Shared<
BoxFuture<
'static,
std::result::Result<Arc<plan::ExecutionPlan>, recoco_utils::error::SharedError>,
>,
>,
export_op_execution_contexts: Vec<exec_ctx::ExportOpExecutionContext>,
) -> Result<FlowSetupChange> {
@bashandbone bashandbone merged commit 2dd97f0 into main Mar 13, 2026
51 of 61 checks passed
@bashandbone bashandbone deleted the claude/issue-49-20260310-2124 branch March 13, 2026 21:07
@github-project-automation github-project-automation bot moved this from Backlog to Done in Recoco v1.0.0 Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working upstream-sync Issues for syncing updates with our upstream (cocoindex-io/cocoindex)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Upstream-Sync] [BUG] Execution plan initialized before target setup (upstream bug – PR #1715)

2 participants