mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-13 07:12:27 +00:00
Backports the test fix from #4183 (commit `21ecafe9a` on `main`) to `release/v0.39`. ## Root cause `when optimizing a dataset > cleanups old versions` took its cutoff with `new Date()`. A JS `Date` has millisecond precision; Lance stores version timestamps with nanosecond precision. If the cutoff landed in the same millisecond as the preceding commit, truncating to milliseconds put the cutoff *before* that commit, so the version was not eligible for pruning and `stats.prune.oldVersionsRemoved` came back as `1` instead of `2`. This became possible on this branch with #4160, which changed `cleanupOlderThan` to be passed to the native binding as an absolute timestamp. It is timing- and machine-dependent, which is why it shows up on the fast Linux runners and not locally. ## Fix Wait for the clock to tick over to the next millisecond before capturing the cutoff, so the cutoff is strictly later than every commit the test made. Same change that is already on `main`. ## Observed failures - https://github.com/lancedb/lancedb/actions/runs/34945208311/job/104323950514 — scheduled NPM Publish on `main` at `ffe94a65a`, before #4183 landed. - https://github.com/lancedb/lancedb/actions/runs/35257750543 — #4216 (`update-lance-12.0.0-v0.39`), which targets this branch and so does not have the fix. ## Verification This is a flake, so there is no deterministic local repro to show red-then-green. The change is byte-identical to the one merged in #4183; `main` has had three green NPM Publish runs since it landed, and no recurrence of this test on `main`. Note: `delete unverified`, immediately below, still uses `new Date()` for its cutoff. It asserts `toBeGreaterThan(1)` rather than an exact count, so it has one version of slack, but it is the same latent race. Left alone here to keep this a faithful backport — happy to harden it on `main` and backport that too. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>