Skip to content

fix(python): expose optimize compaction options - #3870

Merged
Xuanwo merged 36 commits into
mainfrom
gatekeeper/fix-2325-1
Oct 26, 2026
Merged

Xuanwo merged 36 commits into
mainfrom
gatekeeper/fix-2325-1

Conversation

@lancedb-gatefixer

@lancedb-gatefixer lancedb-gatefixer Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • expose typed compaction options on synchronous and asynchronous table optimization
  • translate validated Python options into native Lance compaction settings
  • document the row-based steady-state limit and first-pass/source-budget caveats
  • carry the Lance beta.15 fragment-exclusion option through the typed Python API

Root cause

The native Python optimize binding always constructed default compaction settings, and the public AsyncTable API offered no way to lower the fragment row target. Wide-row fragments therefore remained compaction candidates on every later optimize call, repeatedly rewriting the accumulated table.

Limitations

This is an explicit row-based mitigation, not byte-native task sizing or a hard memory cap. Callers must derive target_rows_per_fragment from expected row size. Existing oversized fragments are rewritten whole on the first pass; max_bytes_per_file limits output file size rather than compaction memory; and source budgets admit whole planned tasks, so a budget below the first task performs no compaction. Splitting tasks by a byte budget or returning a planner error requires a Lance-side change.

Validation

  • cargo check --release -p lancedb-python
  • cargo clippy --quiet -p lancedb-python
  • cargo fmt --all --check
  • ruff format --check python tests
  • ruff check python tests
  • uv run --no-sync pytest python/tests/test_table.py -k optimize_compaction -q (16 passed)

Fixes #2325

@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 repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot added bug Something isn't working Python Python SDK Rust Rust related issues labels Aug 6, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

lancedb-gatekeeper[bot]

This comment was marked as outdated.

lancedb-gatekeeper[bot]

This comment was marked as outdated.

@Xuanwo Xuanwo added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 10, 2026
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 14, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-risk Latest Gatekeeper recommendation includes a non-blocking risk. label Aug 14, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Aug 14, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

# Conflicts:
#	python/python/lancedb/__init__.py
lancedb-gatekeeper[bot]

This comment was marked as outdated.

lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 25, 2026
@lancedb-gatefixer

Copy link
Copy Markdown
Contributor Author

Addressed in 2a85c0e. Added -s rust/lancedb/tests to the documented snippet-regeneration command and listed that directory alongside the documentation test sources.

Ran the documented command with temporary output and checked its shell syntax. The regenerated storage snippet module exactly matches the checked-in module, including the Rust compaction tuning tab.

@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 25, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 25, 2026
@lancedb-gatefixer

Copy link
Copy Markdown
Contributor Author

Blocked: Linux (NodeJS 26) fails an inherited approximate-search recall assertion outside this compaction-options repair.

The verified remote head is 2a85c0eb9b11743f7b62f2694dd12c8759d745ca on gatekeeper/fix-2325-1. Its failed job reports one failing test, IVF search effort › preserves effort 0 through execution and probe precedence: recall is 0.375, below the expected minimum 0.5. The other 1,594 tests pass.

I inspected the check, job logs, test fixture, and repair diff. The identical test passes in NodeJS 26 on exact main, dcfef7c5ab259d2ce36003b6d6bf10c6de22cd9e. Node sources, Cargo manifests/lockfile, and workflows match main; the Rust core changes only re-export compaction types. Main is already included in this head. The evidence does not justify an issue-scoped code change, and no merge, commit, or push was made.

Please have a maintainer rerun the failed NodeJS 26 job. If it recurs, stabilize the upstream approximate-recall test or index-training fixture on main while preserving its effort and probe-precedence assertions; I can then integrate that correction.

@lancedb-gatefixer

Copy link
Copy Markdown
Contributor Author

Blocked: Linux (NodeJS 26) and Minimum dependencies fail inherited tests outside this compaction-options repair.

The verified remote head is 2a85c0eb9b11743f7b62f2694dd12c8759d745ca on gatekeeper/fix-2325-1.

  • Linux (NodeJS 26): IVF search effort › preserves effort 0 through execution and probe precedence reports recall 0.375, below the expected 0.5. The other 1,594 tests pass.
  • Minimum dependencies: test_remote_connection_after_fork fails with Remote connection hung after fork because the child remains alive after its 15-second deadline. Pytest stops with 1,683 tests passed.

I inspected both live checks and job logs and compared the failing paths with exact main, dcfef7c5ab259d2ce36003b6d6bf10c6de22cd9e. Both tests pass there: NodeJS 26 and Minimum dependencies. Node sources, dependency manifests/lockfiles, workflows, the fork test, and Python/Rust fork-runtime implementations match main. A focused run of the fork test in the uv-managed local Python 3.13 environment also passes (1 test); main's minimum-dependency job provides the Python 3.10 comparison.

Main is already included in this head. The evidence points to intermittent failures and does not justify a speculative repair change. No merge, source change, commit, or push was made.

Please have a maintainer rerun both failed jobs. If either recurs, land a focused correction on main for the approximate-recall fixture or fork/runtime behavior, preserving the assertions; I can then integrate that correction and validate this branch.

Retain both retrain and compaction_options on RemoteTable.optimize, preserving upstream signature alignment and the existing compaction API.

Validation: rebuilt the Python extension; 66 signature and optimize tests plus the Python tuning example pass. Python lint and Python/Rust formatting checks pass. Root Ruff retains 49 inherited documentation diagnostics in files identical to main.
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 2026
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 2026
@lancedb-gatefixer

Copy link
Copy Markdown
Contributor Author

Blocked: Rust / deny fails on inherited zstd security advisories that require an upstream dependency migration outside this compaction-options repair.

The verified remote head is b56b9ad6ac69f999b58b354e45aae228a92a5121 on gatekeeper/fix-2325-1. The failed deny job reports four errors:

  • zstd 0.13.3: RUSTSEC-2026-0391; patched in >=0.14.3.
  • zstd-safe 7.2.4: RUSTSEC-2026-0398 and RUSTSEC-2026-0403; patched in >=8.2.0.
  • zstd-sys 2.0.16+zstd.1.5.7: RUSTSEC-2026-0410; patched in >=2.1.2.

Bans, licenses, and sources pass. I inspected the job logs, compared all Cargo manifests, Cargo.lock, deny.toml, and workflows with current main 180eaaf68eae595e0948f3bb2f02974d4cf0535e, and verified the dependency constraints with locked, offline Cargo metadata. Those inputs are unchanged by this repair, and main is already included in this head. Arrow IPC 58.4.0 requires zstd ^0.13.0, excluding the patched zstd release. Main's earlier deny run passed before this failing run. No merge, source change, or push was made.

Please land a dependency migration on main that allows the patched zstd family; I can then integrate and validate it. Alternatively, explicitly authorize that separate dependency migration on this repair branch.

lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 2026
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 2026
@lancedb-gatefixer

Copy link
Copy Markdown
Contributor Author

Addressed in bcf49ab. Added the Python, TypeScript, and Rust Blob v2 directories to the documented snippet-regeneration command and source list.

The old command omitted 21 multimodal exports. The updated command exactly reproduces the checked-in multimodal, Blob/pylance, and compaction snippet modules; shell syntax validation also passes.

@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 2026

@lancedb-gatekeeper lancedb-gatekeeper 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.

✅ Gate recommendation: approve.

The documentation follow-up is verified: the updated regeneration command exactly reproduces the checked-in multimodal, Blob/pylance, and compaction snippet modules. The earlier source-list suggestion is addressed.

The compaction implementation and dependencies are unchanged, so the prior focused signature, optimization, and storage-example verification remains applicable. Remote optimization remains unsupported.

Lowering the fragment row target remains a useful steady-state mitigation for repeated wide-row rewrites, not a hard byte-based memory cap. Existing oversized fragments are rewritten whole on the first pass; source budgets admit whole tasks and can produce no work when the first task exceeds the budget; max_bytes_per_file limits output file size rather than compaction memory.

The Python/Rust tuning examples correctly remain unpublished drafts pending confirmed release availability, with the TypeScript limitation documented.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 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.

The final documentation follow-up matches the reviewed fix and leaves the compaction implementation unchanged. The native build and applicable CI pass, and generated exports are complete. Gatekeeper recommends approval; no blocking findings remain.

@Xuanwo
Xuanwo merged commit 3352bf4 into main Oct 26, 2026
37 checks passed
@Xuanwo
Xuanwo deleted the gatekeeper/fix-2325-1 branch October 26, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance. Python Python SDK Rust Rust related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(python): No Batch Size for optimize

1 participant