Skip to content

Publish function pipeline records after results commit (ITL-1412) - #509

Merged
eywalker merged 5 commits into
mainfrom
eywalker/itl-1412-a-function-nodes-pipeline-records-must
Nov 23, 2026
Merged

eywalker merged 5 commits into
mainfrom
eywalker/itl-1412-a-function-nodes-pipeline-records-must

Conversation

@eywalker

@eywalker eywalker commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes ITL-1412

Publication timing and commit counts

With distinct tables in one Delta store, the first async node's flush now publishes its own records. The sibling's records wait for the sibling's result commit. Fresh readers observed the following histories as (result rows, pipeline rows, dangling references).

Main This PR
(4,0,0) → (8,8,0) (4,0,0) → (4,4,0) → (8,4,0) → (8,8,0)

In the controlled Delta fixtures, the number of writes per physical table stayed the same except the async split-store case with one shared pipeline table. There main issued one eight-row pipeline WRITE after the first result commit. This PR adds one pipeline WRITE, for two four-row WRITEs total, one after each result store commits. Each result table still gets one four-row WRITE. With both tables shared in a single store, both versions use two four-row WRITEs per table in sync and one eight-row WRITE per table in async. In a threaded async fork, narrowing each flush can also change which interleaved pending rows are grouped into a commit.

Fix

A failed result write previously left pipeline records queued. Error cleanup could then publish those records even when the result write failed again or the database had already dropped the batch. A broad async flush could also publish a sibling's records while its results were pending in a separate store.

Function nodes now use the same commit path in sync runs, async runs and error recovery. A pipeline record stays readable in the database's pending queue, with an in-memory dependency on its result batch. A successful result commit releases its dependent records for publication. A failed or dropped batch withdraws them, while records that still await another result stay pending. A later result retry can store results for a rerun to reuse. Table commit errors identify the store and table.

Mixed stores and intentional discards

In-memory queues now track result dependencies, so mixed stores commit at the node's batch boundary. The 48-case cross-backend matrix preserves main's pipeline write counts, Delta result histories and whole-store flush counts. A separately attached in-memory result table is the exception. Main left its rows pending. This PR promotes them before the retained pipeline records commit. Pending-aware point, batch, filtered and full-table reads see the same rows, and the joined node view still returns those results.

A no-op pipeline store leaves separate in-memory results pending, as on main. A no-op result store is a declared discard. It still lets the pipeline store record processed inputs, as on main. Those pipeline records refer to results that were never stored.

Internal database protocol

ArrowDatabaseProtocol requires pending_result, guard_record, fail_pending_result, flush_result_batch, flush_batch, and stores_records. Jobs call the declared methods directly. Every supplied Arrow database supports the contract: DeltaTableDatabase, InMemoryArrowDatabase, ConnectorArrowDatabase, NoOpArrowDatabase, and the forwarding ExtensionAwareDatabase. The no-op store still allows bookkeeping for explicitly discarded results.

The test implementation ProtocolDatabase forwards all required methods. The other test doubles inherit or delegate them:

  • FailingCommits and FailPipelineRecords in test_job_batched_commits.py.
  • FailPipelineRecords in test_async_failure_does_not_hang.py.
  • FailingWrites and CountingWrites in test_job_run_in_event_loop.py.
  • CrashOnFlush in test_job_crash_recovery.py and FaultyStore in test_store_write_failure.py.
  • ThirdPartyDatabase and DeclaringThirdPartyDatabase in test_database_capability.py.
  • CountingDatabase in arrow_work_counter.py, _UndeclaredDatabase in test_operator_node_cache_mode.py, and _FailingFlushDatabase in test_side_effect_job_node_reads.py.

DatabaseWithoutCommitGuards is the negative runtime conformance fixture. The connector doubles implement the connector interface and run through ConnectorArrowDatabase. The published docs use the supplied implementations and the job guide describes their commit ordering without inviting implementations of the internal protocol.

Review coverage

Reviewer finding Behavior on main Regression test
Failed result commit still publishes pipeline records Reproduced with one Delta store on sync and async. Four pipeline rows became durable with zero results. test_result_failure_withdraws_records_and_rerun_recovers (retryable fault, one and two stores, batch sizes 1 and 10)
Pipeline records point to discarded results Reproduced on sync and async through Delta's dropped-batch path. Four dangling references survived a later flush. test_result_failure_withdraws_records_and_rerun_recovers (dropping fault) and test_failed_side_effect_result_leaves_no_completion_record
Async batch commit publishes a sibling's records first Main's shared Delta queue published both branches early, with zero dangling references in the no-fault run. Attaching separate Delta result stores through the existing node API reproduced dangling references. test_async_flush_exposes_only_records_with_durable_results (fresh readers after each flush, with distinct and shared pipeline tables)
In-memory pipeline with Delta results flushed per row, and a shared in-memory store made extra whole flushes Main made five Delta commits for 50 sync rows at cadence 10 and 13 whole flushes for 1,000 in-memory rows at cadence 100. The earlier PR head made 50 and 1,024. test_mixed_database_batches_keep_main_cadence, test_shared_in_memory_store_keeps_whole_flush_count, and test_promoting_memory_results_preserves_public_read_views
No-op result wiring suppressed pipeline records Main recorded the processed inputs. The earlier PR head dropped those records. test_noop_result_store_keeps_pipeline_records
Connector dependency path lacked a job-level test Main could publish connector pipeline records during a pending result flush. With separately attached connector results, main did not attempt the result upsert. test_connector_job_keeps_only_ready_records_on_result_failure and test_connector_result_failure_withdraws_its_pipeline_records, with an Arrow-capable connector double
Result commit error did not identify the failed store and table independently Main labeled a failed result commit with the pipeline namespace. test_result_commit_error_names_the_actual_store_and_table, which checks the error before inspecting any stored rows
A store must support the complete internal commit contract Main ran the old database contract. The revised runtime conformance check requires guarded commits across the library stores. test_library_databases_conform_to_the_commit_protocol and test_complete_protocol_database_preserves_main_rows_and_flushes (sync and async, pipeline/result/both/shared placements)

Against an untouched archive of main, 21 new fault and early-publication cases failed. The 15 controls passed on both versions, covering shared-table commit counts and pending reads through point, scan, filter, recomputation, cache and joined views. All 300 targeted checks passed on the follow-up, including the existing batched-commit and Delta commit-cost tests unchanged. An additional 95 in-memory database tests passed. The follow-up's 59 cases produced 25 failures on main and 26 on the original PR head. The connector and independent error-naming cases fail on main. The cadence and no-op behavior regressions fail on the original PR head. The required-protocol revision passed 611 targeted tests with one expected failure. The batched-commit and Delta commit-cost assertions are unchanged. The batched-commit fake forwards the result flush through its existing fault injector. The final archived comparison covers the 48 library-backend combinations and the three-node Delta cold and rerun fixture. It preserves the earlier async publication timing and separate in-memory result promotion decisions. Golden hashes match.

The crash-recovery fixture now intercepts the scoped pipeline-table flush, which replaces the database-wide flush during a node commit. The process still exits at the same durability boundary between the result and pipeline writes. A fresh process still verifies what survived and what rerun work was needed.

Generated with Codex on behalf of the developer

Summary by CodeRabbit

  • Bug Fixes

    • Pipeline records are published only after their referenced results commit. Failed result writes withdraw dependent pipeline records, preventing durable references to missing results.
    • Database write errors identify the affected table.
    • Failed writes can be retried, and interrupted or discarded results are handled without publishing dependent records.
    • No-op result databases continue to support pipeline bookkeeping without storing results.
  • Documentation

    • Clarified result commit ordering, failure handling, and no-op result database behavior.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Function-node commits now coordinate result batches and pipeline records. Database adapters track pending commit dependencies, and dependent pipeline records are published after result commits succeed. The changes also add table-scoped write-error reporting, database protocol methods, tests, and documentation.

Changes: Result Commit Ordering

Layer / File(s) Summary
Pending commit tracking
src/orcapod/databases/_pending_commits.py
Adds commit-attempt tracking for dependent records. The coordinator selects unblocked rows for flushing, withdraws guarded records after failed attempts, and restores rows when needed.
Database commit support
src/orcapod/protocols/database_protocols.py, src/orcapod/databases/*
Extends the database protocol and database adapters with pending-result dependencies, record guards, scoped flush methods, and storage capability properties. The extension-aware wrapper delegates these operations.
Function-node commit flow
src/orcapod/core/nodes/function_node.py, src/orcapod/pipeline/job.py, src/orcapod/errors.py, src/orcapod/utils/database_errors.py
Function nodes flush result batches before pipeline records and guard records on pending results. Flush errors can identify a table, and job finalization reports the path of the database view that failed.
Commit-flow validation and documentation
tests/test_pipeline/*, tests/test_databases/test_in_memory_database.py, changelog.d/ITL-1412.md, docs/concepts/pipeline-job.md, docs/dev/design_issues/ITL-1412-FC1.md
Adds tests for commit ordering, failures, retries, pending-record visibility, and database protocol conformance. Updates the changelog and documentation to describe the commit behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant FunctionNode
  participant PipelineDatabase
  participant ResultDatabase
  participant PendingCommits
  FunctionNode->>PipelineDatabase: guard and enqueue dependent pipeline record
  FunctionNode->>ResultDatabase: flush result batch
  ResultDatabase->>PendingCommits: resolve result commit attempt
  FunctionNode->>PipelineDatabase: flush ready pipeline batch
Loading

Possibly related PRs

Merge Risk: Minimal · up to f3b64

Pipeline records are now published only after their referenced results commit, and failed or discarded result batches withdraw their pending records. Reviewers found no concrete defects, and the targeted fault-injection and conformance tests cover the changed behaviour. The one internal-protocol change, the six newly required database methods, only affects external implementers of that protocol. The change is ready to merge.

Security architecture risk: Low · up to f3b64

The change prevents pipeline records from being published before their results are stored. Remaining risk is limited to database adapters that need to adopt the new contract and to overlapping writes on a shared database, which can leave a record queued indefinitely.

Retained concerns

  • Low · reliability · inferred: If another execution context fails an attempt after a caller obtains its token but before the caller registers a guard, the coordinator still accepts the guard. The failed token is no longer tracked for resolution, so the row can remain readable in the pending queue but never publish. Duplicate detection can then prevent a retry from replacing it. This is a new failure-recovery risk in the shared queue; ordinary single-loop execution does not establish the required interleaving.
  • Low · architecture · observed: The new commit contract is not backward compatible with adapters that implement only the base interface. An unupgraded adapter can fail conformance checks or fail a function run when a new operation is called. Built-in adapters have implementations; the upgrade constraint applies where callers supply their own adapters.
Security review details

Security Blast Radius

  • inferred — In the compared in-memory path, publication remains within the existing database root's shared queues. A failure can withdraw guarded records in a separately attached pipeline store, but only where the writer explicitly registered those records against that attempt.

Trust Boundaries and Controls

  • observed — The in-memory result lookup checks the referenced ID against pending and committed state. Failure cleanup matches each guarded ID against the exact attempt object, rather than withdrawing all pending records at the destination.

Hardening Proposals

  • proposed — Give commit tokens an explicit failed terminal state and make guard registration and enqueue consistent with attempt completion. Either enforce single-owner access to each shared queue or test recovery when independent callers share it.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main behavior change: function pipeline records are now published only after their referenced results commit. The changeset matches this. The changelog, docs, function_node, pendin…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main behavior change: function pipeline records are now published only after their referenced results commit. The changeset matches this. The changelog, docs, function_node, pending-commit coordinator, database protocol and per-backend implementations, and tests all implement or verify that ordering. The ITL-1412 reference is a ticket ID and does not add noise. The title is 8 words and 65 characters, so it fits the short-title guidance.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ba71104 and f3b64bd.

Files selected for processing: 2

  • src/orcapod/databases/in_memory_databases.py
  • tests/test_databases/test_in_memory_database.py

Limit details: You’ve used the included review currently available. Your 102 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Recent review details

Context from checks skipped due to timeout: 1

  • GitHub Check: CodeRabbit
Additional context used

Code guidelines: 1

CLAUDE.md — auto-discovered
Path-based instructions: 1

Source excerpt: Documents written during development are kept in the repository, under `docs/dev/` (developer, November 16, 2026; ITL-1169): Never put them in the published documentation (`docs/` outside `docs/dev/`) or at the top level of...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • src/orcapod/databases/in_memory_databases.py
  • tests/test_databases/test_in_memory_database.py
Additional comments: 2

src/orcapod/databases/in_memory_databases.py: 1

408-408: Data Integrity & Integration

The claimed scenario needs a guarded row and a result row to share one table key. The only repository producers write guarded pipeline rows under _versioned_pipeline_path and read dependencies from record_path. These paths end with pdb_v1 and rdb_v1, so they map to different keys. At a result key no guard exists, so take_ready promotes the whole batch before finish(committed=True). The blocked case that would let a dependent record publish early does not occur with the repository's producers.

tests/test_databases/test_in_memory_database.py: 1

336-378: LGTM!

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.78827% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/orcapod/core/nodes/function_node.py 90.24% 4 Missing ⚠️
src/orcapod/databases/_pending_commits.py 96.55% 3 Missing ⚠️
src/orcapod/databases/connector_arrow_database.py 92.50% 3 Missing ⚠️
src/orcapod/databases/in_memory_databases.py 95.00% 3 Missing ⚠️
src/orcapod/databases/extension_aware_database.py 91.30% 2 Missing ⚠️
src/orcapod/databases/delta_lake_databases.py 96.96% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/orcapod/databases/noop_database.py 100.00% <100.00%> (ø)
src/orcapod/errors.py 100.00% <100.00%> (ø)
src/orcapod/pipeline/job.py 96.26% <100.00%> (+0.01%) ⬆️
src/orcapod/utils/database_errors.py 100.00% <100.00%> (ø)
src/orcapod/databases/delta_lake_databases.py 92.47% <96.96%> (+0.23%) ⬆️
src/orcapod/databases/extension_aware_database.py 93.42% <91.30%> (-1.23%) ⬇️
src/orcapod/databases/_pending_commits.py 96.55% <96.55%> (ø)
src/orcapod/databases/connector_arrow_database.py 97.33% <92.50%> (-0.70%) ⬇️
src/orcapod/databases/in_memory_databases.py 97.09% <95.00%> (-0.69%) ⬇️
src/orcapod/core/nodes/function_node.py 95.16% <90.24%> (+0.08%) ⬆️

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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