Skip to content

feat(core): row spool for rows fetched by number (ITL-1464) - #559

Closed
eywalker wants to merge 3 commits into
mainfrom
eywalker/itl-1464-row-spool
Closed

eywalker wants to merge 3 commits into
mainfrom
eywalker/itl-1464-row-spool

Conversation

@eywalker

@eywalker eywalker commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Draft, a step of ITL-1464 (the issue stays open). Nothing uses it yet, so no result, hash, stored row or golden value can move.

What this does

orcapod.core.row_spool.RowSpool holds rows that are fetched later by row number: append(table), take(row numbers), discard(row numbers), close(). The async joins will keep their join keys in memory and the rows behind them here; the transport may use it for its own spilled rows.

  • Rows stay in memory up to a byte limit (64 MiB by default, an argument). Beyond it, the rows in memory become one uncompressed Arrow IPC file, read memory-mapped. Nothing is created on disk below the limit.
  • root is an argument; by default the system's temporary directory. The directory is private to the user.
  • A file is deleted once every row in it is discarded. The rest goes at close() (a context manager, so at a normal end, an exception and a cancellation), when the spool is collected, and at interpreter exit.
  • A killed process leaves its directory; the next process that spills there removes it. Each directory holds a lock file its process keeps locked, so a live process's directory is never removed. Without fcntl (Windows) nothing is swept.

Tests

tests/test_core/test_row_spool.py: rows by number in any order at three limits, with two tags, a list and an extension column; null under a non-nullable flag; slices not pinning their parent; discarding; every end of a spool's life (close, exception, cancellation, collection, process exit, killed process swept, live process kept, forked child).

Not here

Mentions ITL-1464.

🤖 Generated with Claude Code

Review round 1: finding -> test

Finding Test
A fork while another thread holds the directory guard hung the child test_a_forked_child_neither_waits_for_nor_touches_its_parents_spools[guard_held]
A forked child could delete its parent's segment the same test, [inherited]; every use in another process now raises
A lock file inherited by a child that outlives its parent test_a_child_that_outlives_its_killed_parent_holds_none_of_its_locks[outlived]
A failed spill kept the append and a partial file test_a_failed_spill_leaves_the_spool_as_it_was, test_a_first_append_that_fails_decides_nothing
A process killed before it made its lock file left its directory test_a_process_killed_before_it_locked_its_directory_is_swept, test_a_removal_that_stopped_part_way_is_finished
Threads sharing one spool; request sizes; supported tables stated in the module docstring (threads: see round 2; the caller bounds what it asks for; normalized tables with a column)

Added for the transport: table() and slice(start, length), zero-copy, valid after close() (test_the_table_is_mapped_and_not_copied, test_a_table_outlives_its_spool).

Review round 2: finding -> test

Finding Test
A fork while the root's lock was being made left it locked by the child test_a_child_that_outlives_its_killed_parent_holds_none_of_its_locks[root_lock]
The same for a process directory not recorded yet the same test, [unpublished]
A read in another thread against close test_a_close_waits_for_a_read_of_another_thread, test_threads_append_and_read_one_spool

The locks are now POSIX record locks, which a child does not inherit, so no fork hook has to find them (test_a_process_never_sweeps_its_own_directory covers their one catch). Each spool has a lock: one call at a time, close waits for a running call, a later call raises. The one-owner contract of round 1 is replaced by this. take of a discarded row stays a precondition of the caller, as documented.

…isk (ITL-1464)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

eywalker and others added 2 commits November 25, 2026 01:41
…nd slices without copying (ITL-1464)

A forked child neither waits for a lock of its parent's threads nor touches its parent's
files; a failed spill leaves the spool as it was; an unlocked or partly removed directory is
swept. table() and slice() give rows through their mappings and outlive the spool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a time across threads (ITL-1464)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.93878% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/orcapod/core/row_spool.py 96.93% 9 Missing ⚠️
Files with missing lines Coverage Δ
src/orcapod/core/row_spool.py 96.93% <96.93%> (ø)

... and 5 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.

@eywalker

eywalker commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of the ITL-1464 draft group. The async-route work continues as ITL-1347 stage 5 (ITL-1845). The SpiralDB read work landed in #687 and #679, and continues in #683.

Posted by a Claude Code agent on behalf of @eywalker.

@eywalker eywalker closed this Dec 2, 2026
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