Skip to content

feat: expose a public toggle for disable_transaction_file - #11232

Merged
Xuanwo merged 2 commits into
lance-format:mainfrom
vaibhavdabas16:feat/7486-disable-transaction-file
Nov 26, 2026
Merged

Xuanwo merged 2 commits into
lance-format:mainfrom
vaibhavdabas16:feat/7486-disable-transaction-file

Conversation

@vaibhavdabas16

@vaibhavdabas16 vaibhavdabas16 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7486

Summary

disable_transaction_file was plumbed end to end but could only be turned on from tests. This adds a public switch:

  • WriteParams::disable_transaction_file (Rust), forwarded by InsertBuilder.
  • CommitBuilder::with_disable_transaction_file(bool), in both lance and lance-table-runtime.
  • disable_transaction_file= on lance.write_dataset (Python), as a thin wrapper over WriteParams.

When it's set, the commit stores its transaction only in the manifest's inline transaction_section, skips the _transactions/ file, and sets FLAG_DISABLE_TRANSACTION_FILE.

The setting is per commit, because the flag is not inherited: a later commit that leaves it unset writes the file again and drops the flag. The default stays false; turning it on by default is #7487.

Durability: with the file disabled, the inline copy is the only record of the transaction.

  • CommitHooks::inlines_transaction keeps the transaction inline regardless of MAX_INLINE_TRANSACTION_BYTES on the new-dataset, regular/rebased and detached commit paths.
  • A transaction above the inline section's u32 length prefix is rejected with InvalidInput before anything is published.
  • An empty transaction file path is recorded as None in the in-memory manifest, matching what is read back from storage.

Compatibility:

  • Releases older than 1.0.0 refuse to write to such a version.
  • Readers older than 14.0 return no transaction for it and can't rebase across it. The docs say to keep the file when older clients read transaction history or commit concurrently.

This is a breaking change for Rust callers that build WriteParams with an exhaustive struct literal. Java bindings aren't included and can follow in a separate PR with the same parameter name.

Tests

  • test_disable_transaction_file_applies_to_its_commit_only: no transaction file is written, the flag is set, a freshly opened dataset reads the inline transaction, and a following append writes the file and clears the flag.
  • test_large_transaction_inlined_when_transaction_file_disabled: create, append and a detached commit with a transaction above the spill threshold stay inline and read back.
  • test_inlines_transaction in lance-table-runtime: the inline decision, including the u32::MAX boundary, using lengths only.
  • Python: test_disable_transaction_file covers the same behavior through write_dataset.

Local verification

  • cargo test -p lance-table-runtime --lib -- inlines_transaction retry: 17 passed.
  • cargo test -p lance --lib -- transaction: 166 passed.
  • cargo test -p lance-table --lib: 1698 passed.
  • cargo fmt, ruff, ruff-format and typos pass.
  • Not run locally: clippy, and the Python test (no maturin build on my machine).

@github-actions github-actions Bot added A-python Python bindings enhancement New feature or request labels Nov 18, 2026
@vaibhavdabas16
vaibhavdabas16 marked this pull request as ready for review November 19, 2026 09:17

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Nov 19, 2026
@vaibhavdabas16

Copy link
Copy Markdown
Contributor Author

I pushed a fix for the review (d9fbb36). Could a maintainer add the breaking-change label? As a fork contributor I don't have permission to. It's needed because WriteParams gains a public disable_transaction_file field, so Rust code that builds the struct with an exhaustive literal has to set it.

@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 21, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 21, 2026
Xuanwo added a commit that referenced this pull request Nov 23, 2026
## Summary

Use the existing
`lance_table::format::Transaction::try_from(&Transaction)` conversion in
the two places that rebuilt the format wrapper by hand:

- detached commit collision retry, when rebuilding the inline
transaction copy
- injected foreign-commit test helper

Also correct the `format::Transaction` docs. The wrapper holds a
`pb::Transaction` message in memory; the manifest writer serializes it
at `write_protobuf`. Because `inner` and `From<pb::Transaction>` are
public, wrapping does not imply validation. The reverse `From` only
moves the message out without another conversion.

## Behavior and compatibility

- `lance_table::format::Transaction`, `inner`, `as_pb`, `CommitHandler`,
and `ManifestWriter` are unchanged.
- No durable-format change; inline/spill decisions and schema
classification remain in their existing paths.
- Commit outcome verification still compares durable protobuf messages,
preserving the rewrite frag-reuse case.
- The detached retry still only rebuilds the inline copy; the external
`.txn` file is still written once before the retry loop.
- The injected foreign-commit test still exercises the same retry path
through the shared conversion.

## Validation

- `cargo fmt --all -- --check`
- `cargo clippy --all --tests --benches --profile ci -j 8 -- -D
warnings`
- `cargo test -p lance-table --lib --profile ci format::transaction`: 4
passed
- One `cargo test -p lance --lib --profile ci -j 1 --no-run` link; 18
targeted runtime tests passed from the same binary:
  - 8 commit outcome and transaction-file tests
- 3 injected foreign-commit/raw-arrow retry tests (one rstest case pair)
  - 7 dataset transaction inline/external/detached tests

There is no deterministic test for the detached random-version collision
retry itself; that branch is compile-covered, and the same conversion is
exercised by the injected foreign-commit tests. The detached
first-attempt path is covered by `test_list_detached_manifests`.

No diff overlap with #11232 (inline toggle), #11021 (expected-head
mode), or #11280 (test metadata); none changes these conversion sites.
@vaibhavdabas16

Copy link
Copy Markdown
Contributor Author

Hi @Xuanwo, when you have a moment, could you take a look at this one or point me to the right reviewer? It exposes disable_transaction_file as a public write option (#7486). The durability issue from the Gatekeeper review is fixed (large transactions stay inline when the file is disabled), and Gatekeeper now approves. It still needs the breaking-change label, since WriteParams gains a field, and the main CI needs maintainer approval for this fork PR. Thanks!

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 25, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @vaibhavdabas16. I added breaking-change and authorized the fork CI.

Merge blocker. With the external file disabled, the inline section is the only transaction record. Its writer casts the encoded byte length to u32. Please reject a length above u32::MAX before publishing the manifest and test the boundary without allocating 4 GiB. This finding comes from code inspection.

Please also document the v14 minimum for clients that need transaction history or rebase across an inline-only commit. On a fixture constructed from real append bytes in this layout, v14.0.3 read the Append. v9.1.0-beta.2 scanned both rows but returned no transaction and failed to rebase. The v13.0.0 schema and reader source confirm the same limitation. Mixed deployments with older transaction consumers should keep the external file.

When rebasing onto the current commit runtime, please retain #11411’s keyed-append guard. The rebase also picks up #11370’s url update for cargo-deny.

Add WriteParams::disable_transaction_file and
CommitBuilder::with_disable_transaction_file, so a commit can store its
transaction only inline in the manifest and skip the separate file
under _transactions/. The setting applies per commit: later commits
that leave it unset write the transaction file again and drop the
writer feature flag. Python's write_dataset gains the same option.

With the file disabled, the inline copy is the only durable one, so it
is kept regardless of size on the new-dataset, regular and detached
commit paths. A transaction too large for the inline section's u32
length prefix is rejected before anything is published.

An empty transaction file path is recorded as None in the in-memory
manifest, matching what is read back from storage.

Readers older than Lance 14.0 return no transaction for such a version
and cannot rebase across it; the docs say so.

Closes lance-format#7486
@vaibhavdabas16
vaibhavdabas16 force-pushed the feat/7486-disable-transaction-file branch from d9fbb36 to e8d9c10 Compare November 25, 2026 18:41
@vaibhavdabas16

Copy link
Copy Markdown
Contributor Author

Thanks @Xuanwo, and thanks for the label and CI approval. I've rebased onto main and ported the change onto the commit runtime as one commit, e8d9c10.

  • u32 limit (merge blocker): CommitHooks::inlines_transaction now returns a Result. With the transaction file disabled, a transaction above the inline limit is still inlined, but one above u32::MAX bytes returns InvalidInput. That happens in create.rs, detached.rs and transaction.rs before any transaction file or manifest is written. test_inlines_transaction covers the boundary with lengths only, no 4 GiB allocation: exactly u32::MAX inlines, u32::MAX + 1 is rejected, and with the file enabled the same length simply isn't inlined.
  • v14 minimum: the WriteParams field, both with_disable_transaction_file builders and the Python write_dataset docstring now say that readers older than Lance 14.0 return no transaction for such a version and can't rebase across it. They recommend keeping the external file when clients older than 14.0 read transaction history or commit concurrently.
  • feat: deduplicate keyed append commits #11411: the keyed-append guard in commit_transaction is unchanged. The port sits on the current runtime and doesn't touch it, so append idempotency is still rejected when the transaction file is disabled.
  • Carried over: the durability fix from the earlier review and the in-memory transaction_file normalization (None rather than Some("")).

Checks run locally:

  • cargo test -p lance-table-runtime --lib -- inlines_transaction retry: 17 passed.
  • cargo test -p lance --lib -- transaction: 166 passed. That includes test_disable_transaction_file_applies_to_its_commit_only and test_large_transaction_inlined_when_transaction_file_disabled.
  • cargo test -p lance-table --lib: 1698 passed.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the rebase. In e8d9c10d, create, detached commit, and each regular commit attempt check the encoded transaction length before publication. The Rust and Python docs now explain the v14 minimum for transaction history and rebase, and the keyed-append guard is intact.

One merge blocker remains in CommitHooks::inlines_transaction. It returns Ok(true) for a length within inline_transaction_limit() before checking whether the section’s u32 prefix can represent that length. The built-in 20 MiB threshold is safe, but a CommitLifecycleHook can supply a larger usize threshold. With the sidecar disabled, the unrepresentable inline section would be the only transaction record.

Please check the section maximum first. Above it, use the sidecar when enabled and return InvalidInput when disabled. A length-only test with a hook threshold above the section maximum would cover both outcomes.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026
inlines_transaction accepted any length within inline_transaction_limit()
before checking that the inline section's u32 length prefix can encode
it. A CommitLifecycleHook may supply a larger limit, so with the
transaction file disabled an unrepresentable inline section could have
been the only transaction record.

Check the section maximum first: above it, use the transaction file when
enabled and reject the commit when disabled.
@vaibhavdabas16

Copy link
Copy Markdown
Contributor Author

Thanks @Xuanwo, fixed in 00e7334.

The decision is now inline_decision(encoded_len, inline_limit, transaction_file_disabled), and it checks the section maximum first. Above u32::MAX it returns Ok(false), so the transaction goes to the external file when that's enabled, and InvalidInput when it's disabled, whatever limit the hook supplies. At or below the section maximum the previous behavior is unchanged.

test_inlines_transaction passes the limit explicitly and adds hook cases with inline_limit = usize::MAX:

  • u32::MAX + 1 goes to the external file when it's enabled.
  • u32::MAX + 1 returns InvalidInput when it's disabled.
  • u32::MAX itself is inlined.

test_commit_hooks_use_default_inline_limit checks that CommitHooks still applies the default limit. cargo test -p lance-table-runtime --lib -- inlines_transaction inline_limit: 10 passed.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Gate recommendation: approve.

The reported fix now checks the inline section’s u32 maximum before the lifecycle hook’s configurable limit. Oversized transactions use the external file when enabled and fail before publication when it is disabled, preserving a durable transaction across commit paths.

Keep the external file when transaction-history readers or concurrent writers run Lance older than 14.0. Larger manifests remain the documented opt-in cost, and keyed append still requires an external transaction file.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing the hook limit in 00e733431. This resolves my section-length blocker. With the hook limit set to usize::MAX, u32::MAX still fits inline. One byte more goes to the external transaction file when enabled and returns InvalidInput when disabled. All nine length-only cases and the default hook test passed in Linux x86 CI.

@Xuanwo
Xuanwo merged commit 979103f into lance-format:main Nov 26, 2026
49 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-python Python bindings breaking-change enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose a public toggle for disable_transaction_file (skip redundant external transaction file)

2 participants