Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8998df2
fix(databases): commit every Delta write to an existing table by MERG…
Nov 23, 2026
8cdf582
Merge remote-tracking branch 'origin/main' into eywalker/itl-1377-del…
Nov 23, 2026
ede6a70
fix(databases): refuse a Delta column name holding a backtick; test t…
Nov 23, 2026
558ddb3
fix(databases): bound a lost Delta commit's retries by 200 attempts, …
Nov 23, 2026
0e7a626
Merge remote-tracking branch 'origin/main' into eywalker/itl-1377-del…
Nov 23, 2026
e218443
perf(databases): merge Delta commits without streaming the pending ro…
Nov 23, 2026
81d00aa
build(deps): require deltalake>=1.6.6; refuse on Delta what deltalake…
Nov 23, 2026
644c6c3
Merge the ITL-1403 branch (deltalake>=1.6.6) into ITL-1377
Nov 23, 2026
8b7c058
docs(databases): several Delta writers, the commit cost, the design i…
Nov 23, 2026
c543f2a
fix(databases): refuse when added what deltalake 1.6 refuses at commi…
Nov 23, 2026
646b10b
test(databases): a storage-typed column carrying another extension na…
Nov 23, 2026
2960b63
test(databases): every review finding of PR 504 has a test, its class…
Nov 23, 2026
d965f04
Merge remote-tracking branch 'origin/eywalker/itl-1403-raise-the-delt…
Nov 23, 2026
4b459cd
Merge remote-tracking branch 'origin/eywalker/itl-1403-raise-the-delt…
Nov 23, 2026
6ba68ce
fix(databases): refuse only what the commit would refuse; second revi…
Nov 23, 2026
a0965f9
fix(databases): walk an error chain once: a lost commit's last error …
Nov 23, 2026
21b9e7e
Merge PR 504's second review (6ba68ce4) into ITL-1377
Nov 23, 2026
d0a2363
fix(databases): the Delta flush is the point of truth; refuse when ad…
Nov 23, 2026
9f4b0a0
Merge PR 504's rework (d0a2363d: the flush is the point of truth) int…
Nov 23, 2026
fef80e1
fix(databases): round-four review of PR 504 (ITL-1403)
Nov 23, 2026
3da5a4b
Merge PR 504's round-four fixes (fef80e1f) into ITL-1377
Nov 23, 2026
40df278
fix(databases): round-five review of PR 504 (ITL-1403)
Nov 23, 2026
a11486c
Merge remote-tracking branch 'origin/eywalker/itl-1403-raise-the-delt…
Nov 23, 2026
e07ce67
fix(databases): refuse a column name deltalake's MERGE reserves (ITL-…
Nov 23, 2026
818665d
Merge origin/main (ca1c35d6: ITL-1412, ITL-1371) into ITL-1403
Nov 23, 2026
0a928d9
Merge PR 504 (818665de: main ca1c35d6, ITL-1412/ITL-1371) into ITL-1377
Nov 23, 2026
9d22a73
Merge remote-tracking branch 'origin/main' into eywalker/itl-1403-rai…
Nov 23, 2026
8ce9ff7
docs(databases): a null in a non-nullable struct field is refused; th…
Nov 23, 2026
d27df65
Merge remote-tracking branch 'origin/eywalker/itl-1403-raise-the-delt…
Nov 23, 2026
93d3e35
test(pipeline): read each Delta commit's added rows from its log entr…
Nov 23, 2026
85aa36d
fix(databases): a commit conflict or an unloadable table keeps its ro…
Nov 23, 2026
a38d139
Merge remote-tracking branch 'origin/eywalker/itl-1403-raise-the-delt…
Nov 23, 2026
ad1c51b
fix(databases): key Delta snapshots by table id; refuse a queued id a…
Nov 23, 2026
a47bb0b
Merge remote-tracking branch 'origin/main' into eywalker/itl-1403-rai…
Nov 23, 2026
1d6bc94
fix(databases): drop a row as stored only if the table holds it now; …
Nov 23, 2026
df4f50f
Merge branch 'eywalker/itl-1403-raise-the-deltalake-requirement-to-16…
Nov 23, 2026
406b236
fix(databases): a reopen drops the snapshot with the handle; a case c…
eywalker Nov 23, 2026
d6a25bb
Merge branch 'eywalker/itl-1403-raise-the-deltalake-requirement-to-16…
eywalker Nov 23, 2026
b2feefd
perf(databases): hold the queued names as a set; the pruning test che…
eywalker Nov 23, 2026
543b1fb
fix(databases): after the reload, skip every input id the table holds…
eywalker Nov 23, 2026
e7e3184
Merge branch 'eywalker/itl-1403-raise-the-deltalake-requirement-to-16…
eywalker Nov 23, 2026
108cfac
Merge origin/main (c70fab52: PR 504 squashed) into ITL-1377
eywalker Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions changelog.d/ITL-1377.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
### Changed

- `DeltaTableDatabase` commits every write to an existing table as a MERGE (it appended a
batch of new ids before), so that a commit fails when another writer added rows after
the table was loaded. The flush then loads the table again and retries. A commit
re-reads the stored rows, so its cost grows with the table: commit in batches (a job
commits every 100 rows by default) rather than per row, above all to tables holding
large values. Measured against the append it replaces, on a local disk: a one-row
commit to a 10k-row table took about 16 ms instead of 5 ms, to a 1 GB table about
66 ms instead of 7 ms, and to a 5 GB table about 1.2 s instead of 8 ms; 2,000 one-row
commits took 451 s instead of 42 s (with deltalake 1.0.2 this MERGE took 249 s: per-row
MERGEs on a table of about 2,000 files are slower on deltalake 1.6.6, so the faster
commits ITL-1403 reports are those it measured, not these). On a cloud store each
commit reads every data file of the table. The stored rows, their values and types,
and every hash, record id and stored path are unchanged; only the order of the rows
within one commit may differ.
- `DeltaTableDatabase` refuses a top-level column whose name holds a backtick, or is
one deltalake's MERGE reserves for its own columns (`__delta_rs_source`,
`__delta_rs_target`, `__delta_rs_operation`, `__delta_rs_delete`,
`__delta_rs_target_insert`, `__delta_rs_target_update`, `__delta_rs_target_delete`,
`__delta_rs_target_copy`; `MERGE_RESERVED_COLUMNS`), with `UnstorableColumnError`
before anything is queued, and an append to a table that already holds one: delta-rs
cannot MERGE such a table, and every commit to an existing table is a MERGE. These
names add to the refusals made when rows are added that ITL-1403 lists, and narrow
its statement that a table written by either deltalake version is appended to by the
other: a table holding such a top-level name, written by any version, takes no
further append.

### Fixed

- Two writers (two `DeltaTableDatabase` objects, or two processes) that committed the
same new record id to one Delta table both committed it, so the id was stored twice,
with `skip_duplicates` true or false. Now the later writer leaves the id the earlier
one stored: each id is stored once. A writer whose commit loses to another writer's
loads the table again and retries, up to 200 attempts; under sustained contention it
can still fail after the last one, and its rows then stay queued for the next flush.
- Two writers creating the same Delta table at once could lose the earlier writer's
rows. The later create now fails and is retried as a MERGE.
- `DeltaTableDatabase.add_records` with `skip_duplicates=False` queued a row whose id
was already queued, and the flush stored both. It now raises `ValueError`, as the
in-memory database does.
- A `skip_duplicates=True` add dropped a row as stored when the table this database had
loaded held its id, also after another writer deleted that row or created the table
again. A row is now dropped as stored only if the table at the path holds its id when
the rows are added (the table is loaded again before any row is dropped).
- A table removed and created again by another writer starts over at version 0: a
`DeltaTableDatabase` that had read the old table could take the new one's ids for the
old one's at the same version, and skip a row with `skip_duplicates=True` as stored
when it was not (ITL-1413). The ids read are now tied to the Delta table's own id as
well as its version, and after a create to a table whose create commit carries this
database's token (`orcapod.create_token` in the commit info).
10 changes: 10 additions & 0 deletions docs/concepts/function-pods.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,16 @@ object that has already loaded the table until its own next commit to that table
a new `DeltaTableDatabase` object reads them at once. This was already the case before
batching; only the re-reading per lookup is gone.

**Several writers.** Two jobs, or two processes, may write to the same
`DeltaTableDatabase` directory at once. Each record id is stored once. A commit to an
existing table is a Delta MERGE that inserts only the ids the table does not hold, and it
fails when another writer added rows after the table was loaded. The database then loads
the table again and retries, so the later writer finds the id stored and leaves it. That
MERGE reads the stored rows, so a commit takes longer as the table grows, and longer still
when the rows hold large values (arrays, images). Commit in batches (the default
`commit_every_rows=100` is fine). Avoid `commit_every_rows=1`, or a node run on its own,
against large tables.

[Pipelines and Jobs](pipeline-job.md) covers jobs in full: nodes, databases, pipeline
blueprints, and saving and loading.

Expand Down
8 changes: 6 additions & 2 deletions docs/dev/design_issues/ITL-1371-LI1.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ handle, where a reopened handle refuses it. The other is pre-existing, as on mai
(ITL-1413): when the table is deleted and recreated at the same path and Delta version, the
held handle's duplicate scan reused the old version's cached ids, so an old id was skipped as
a duplicate and a new one could be written twice. When an add reopens the table (another
identifier, or a refusal checked again), the snapshot is now dropped with the handle (review
of PR 504, round eight); the general fix is ITL-1377's. A connector database compares against the
identifier, or a refusal checked again), the snapshot is dropped with the handle (review
of PR 504, round eight). Fixed in general by ITL-1377 (review of PR 511): the
cached ids are keyed by the Delta table's own id as well as its version (after a create, only
a table whose create commit carries this writer's token is taken for its own), a row is
dropped as a stored duplicate only after the table is reloaded and still holds its id (also
when another writer deleted that row), and every commit to an existing table is a MERGE. A connector database compares against the
stored schema it caches for the ITL-1334 check (`_stored_schemas`), as main's check does, so
a table replaced by another connection is seen as main sees it (pre-existing).

Expand Down
44 changes: 44 additions & 0 deletions docs/dev/design_issues/ITL-1377-CW1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## `src/orcapod/databases/delta_lake_databases.py`

### CW1 — Two writers committing the same new record id to a Delta table both commit
**Status:** resolved
**Severity:** high
**Issue:** ITL-1377

`DeltaTableDatabase` decided which pending ids were new against the version it loaded for
a commit, and committed a batch of new ids by a plain WRITE (append). Another writer (a
second handle, or another process) could commit the same id between the load and the
append. A Delta append never conflicts with a concurrent append, so both commits
succeeded and the id was stored twice. This happened with `skip_duplicates` true and
false, in every `schema_handling` mode, and in any column order. Only a batch that took
the MERGE path (a stored id among its ids) was protected. Two writers creating a new
table at once had the same problem (ITL-1384): the later `mode="overwrite"` create
removed the earlier writer's rows.

What deltalake offers was measured, not assumed:
- None of these makes an append conflict: `CommitProperties(max_commit_retries=0)`,
application transactions, an overwrite with a predicate on the binary id, or the
table-level options of `write_deltalake`. They all commit on top of the concurrent
commit.
- Only a MERGE fails (`CommitFailedError`) when another writer added rows after its load.

**Fix:** every commit to an existing table is a MERGE that inserts only the ids the
table does not hold (`_commit_once`), with `streamed_exec=False`.
- **Retries.** On `CommitFailedError` the flush loads the table again, decides against
it and retries, at most `_COMMIT_ATTEMPTS` (200) times, with a random wait of at most
0.5 s. After the last attempt it raises the conflict, as before.
- **Creating a table.** A new table is created with `mode="error"` and no commit retry,
so a create that lost the race fails and is retried as a MERGE. Without that, deltalake
1.6 commits the losing create on top of the winner's.
- **Duplicates.** The later writer leaves an id the earlier one stored, and so stores
each id once. With `skip_duplicates=False` such an id is skipped without an error, as
an id already stored is today (ITL-1386).
- **Backticks.** delta-rs cannot MERGE a table with a top-level column whose name holds
a backtick, so such a column is refused (ITL-1375).

**Cost.** delta-rs's insert-only MERGE reads every stored row in full: it is a full outer
join, and the binary id column has no file statistics, so no file is skipped. A commit
therefore costs time in proportion to the table's size. ITL-1403 (deltalake 1.6.6) made
that MERGE 2 to 8 times faster. ITL-1406 lists stored layouts that would let it skip
files. Commit in batches (a job's default of 100 rows per commit) rather than per row,
above all to tables holding large values.
20 changes: 16 additions & 4 deletions docs/reference/database-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ Some refusals depend on the values or names as well as the type:
field, so a map with such metadata is refused there.
- A fixed-size list or fixed-size binary read back by Delta with another length or width
than its type is refused on read, never padded or cut.
- Delta refuses a column whose name holds a backtick, or is one deltalake's MERGE reserves
for its own columns (`__delta_rs_source`, `__delta_rs_target`, `__delta_rs_operation`,
`__delta_rs_delete`, `__delta_rs_target_insert`, `__delta_rs_target_update`,
`__delta_rs_target_delete`, `__delta_rs_target_copy`), of any type: delta-rs cannot
MERGE such a table, and every commit to an existing Delta table is a MERGE. A table
that already holds such a column takes no further append. A nested field with such a
name is kept.

A table holds one type per column. An append whose columns differ from the held ones
(stored, or still pending) in field metadata (the column's own, or a nested field's: a
Expand Down Expand Up @@ -100,9 +107,11 @@ a changed field metadata (`SchemaMismatchError`), two names equal under Delta's
folding, a type DataFusion cannot insert or cast into the stored one, and a row Delta
finds invalid (a null in a non-nullable column, a failed CHECK constraint). A CHECK
constraint whose verdict changes by chance would accept such rows on a later try;
Orcapod writes none. Any other failure keeps its rows queued and is raised again by the
next flush, as before: a storage error, a constraint whose evaluation itself fails, a
stored table unreadable for another reason. So a column whose Arrow type Delta keeps
Orcapod writes none. Any other failure keeps its rows queued, as before, and the next
flush tries them again: it writes them if the cause has passed (storage recovered,
another writer no longer committing first) and raises only if that try fails too: a
storage error, a constraint whose evaluation itself fails, a stored table that cannot be
loaded. So a column whose Arrow type Delta keeps
through a recorded type (the "(recorded type)" cells below, every list and map included)
cannot gain a field when schema evolution is on, nor have a nested nullability change:
the record is the column's field metadata, which deltalake 1.5 and later does not let a
Expand All @@ -113,7 +122,10 @@ An append matches columns by name, exactly as Arrow matches them (`a` and `A` ar
columns), never by position. Delta alone refuses two columns, or two fields of one
struct, whose names differ only in case: Delta column names are case-insensitive, so
such a table, or an append that would make one, is refused naming both, before anything
is queued. Rows whose columns are the held table's columns in another
is queued, when Python's `str.lower` finds the pair. Delta folds case as Rust's
`to_lowercase` does, which differs for a few code points (U+1C89 and U+1C8A, for
example): such a pair is found by Delta only, at the flush, which raises once naming the
column (`UnstorableColumnError`), and those rows leave the queue. Rows whose columns are the held table's columns in another
order, each field equal to the held one (the same type at every depth, the same logical
type, the same field attributes), are put in the held order, whether the table was
flushed in between or not. The in-memory database matches them to the rows still pending,
Expand Down
Loading
Loading