Repository navigation
index file I/O: a logical file layer and disk cache over index chunk tables - #31050
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
…ables Proposed contract for reading and writing index files without SQL while the chunks stay rows of the existing hidden tables: identity and versions, engine-level reads with range reads, a fileservice chunk cache keyed by content, engine-level writes with write-through, and compatibility. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… disk cache Record the decisions: the unit is the whole named file, written as chunk rows and into the disk cache only (no memory cache); reads by name rebuild from the rows on a miss; integrity reuses the base-file checksum and the CDC frame footer; FULLTEXT2 adopts first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Snapshot reads are handled by the caller's transaction and the content-addressed name; record the decision and a snapshot-after-merge validation case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A cached file carries a trailing integrity record (format version, length, one checksum); chunk rows keep today's bytes, so no format gate. Rebuilds verify against the metadata checksum by kind; the tail is one file per frame with the shared frame encoding moved out of the GPU package (proposed). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The cached index file is exactly the payload (a tarball stays a tarball); integrity lives in a separate manifest beside it, so path-based consumers read unchanged bytes and chunk rows keep today's format. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Index files live in the shared fileservice disk cache under a reserved namespace, rebuilt from chunk rows on a miss. A new whole-file API pins an open file: pinned files are never evicted and stay counted, deletes wait for the last release, and eviction terminates when only pinned files remain. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…isting capacity A separate directory and cache instance holds index files, sized as a configured share of the existing disk-cache capacity; pinning applies to it only, so table-data eviction is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uild cache use is configurable Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ld per file, removal and sharing rules Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@XuPeng-SH fixed in 1614070 (the cache-key alias in
Tests (both fail on the previous code):
Also merged main (b525cd7). |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: b525cd7bef02f20716be985108a95cddb9a24cf6
Assessment: approve
Reviewed the complete 24-file delta, linked issue, and discussion. The checksum-name alias is fixed and verified through cached Open. Earlier staging, prefetch, directory-retention, and design concerns are resolved. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Isolation preflight and native provenance verification passed with matching current native inputs.
-
Focused identity, cache lifecycle, staging fallback, configuration, internal table-function, and engine transaction/snapshot/prefetch tests passed.
-
Full indexfile and fileservice packages passed under -race. Bounded concurrency stress checks also passed.
-
All 24 discussion keys are reconciled in discussion-assessment.json. Commands, source fingerprints, terminal receipts, and retained logs were verified; the audit is recorded under /home/xupeng/.local/state/mo-bot/jobs/36856002e88b2699a9fd754b/attempt-1/evidence-audit.json and final-validation-receipt.json.
Limitations:
-
Raw CI logs were unavailable; validation claims above rely on audited local execution.
-
No full-cluster or algorithm-adoption run was performed. This PR introduces the reusable layer without adopting it in an index algorithm.
❌ Left the queue · checks failed1 h 56 min in the queue, with no time running CI. So far
The failure is in this pull request. It failed tested alone on top of Reason The merge conditions cannot be satisfied due to failing checks
To get back in the queue
Merge conditions: 2 of 3 metThis pull request
The batch, tested in place
Requeued — the merge queue status continues in this comment ↓. Times in UTC · dashboard · how the merge queue works |
🚫 Left the queue3 h 11 min in the queue, with no time running CI. So far
Reason Pull request #31050 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Hint You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
issue #31051
What this PR does / why we need it:
A logical index file layer over the existing index chunk tables (
index_id, chunk_id, data, tag) shared by HNSW, CAGRA, IVF-PQ and FULLTEXT2, plus a CN-local disk cache for whole index files. Physical storage does not change: chunks stay rows of the hidden tables. No index uses the layer yet; each algorithm adopts it in its own PR (FULLTEXT2 next).Design and decisions:
docs/design/20261024-index-file-io.md.Why
Today every index load streams all chunks through SQL into a temp file, and every write builds
INSERTstatements with each 64 KiB chunk as a bound parameter or hex literal. Nothing is reused between loads, and the writing CN reads its own file back through SQL.Changes
fileservice.IndexFileCache(pkg/fileservice/index_cache.go): its ownDiskCacheinstance whose entries are directories (file + manifest). An entry is published by one rename, opened through one directory handle (os.OpenRoot), and evicted or deleted as a unit. Capacity, eviction, disk-full handling, per-path coordination and restart reuse are the existingDiskCachemechanisms; the directory-entry handling is enabled only on this instance, so table-data caches are unchanged.[fileservice.cache]):index-file-disk-share(default 0, so this PR changes nothing until configured),index-file-disk-path(default<disk-path>-index-file; must not overlapdisk-path),index-file-rebuild-cache(read|none|read-write). Only a CN's SHARED file service gets the cache. The share splitsdisk-capacityand a runtime cache resize.pkg/vectorindex/indexfile, generic for all chunk-table indexes:Open: a cache hit is checked against its manifest (full CRC32-C on the first open in the process, then the length). A miss takes a per-file lock (concurrent misses rebuild once), streams only the file's chunk range through the relation readers of the caller's transaction (snapshot-aware, same workspace visibility as a SQLSELECTin that position), requires every chunk exactly once with its exact length, verifies the metadata checksum, and moves the file into the cache. Cache errors fall back to a rebuild.Write: keeps the file as one local file and writes the rows with internalINSERT INTO <chunk table> SELECT ... FROM index_file_chunks('<token>', start, count)statements of at most 1000 chunks each, so the insert pipeline keeps its primary-key locks, duplicate check and composite key. The local file then moves into the cache without a second copy.File.FDPath()gives path-taking libraries (usearchView, the cuvs tar unpacker) a path to the open descriptor, valid even if the cache evicts the file.index_file_chunks: an internal table function (rejected for non-internal SQL at plan time). It takes a random token bound to the writing transaction, never a path, and runs as a single local scope.Compatibility
index_file_chunksis only planned and executed on the CN that holds the file (childless function scan →compileSingleTableFunction; it fails closed if given an input), and it is never persisted in a view or plan another CN would run.Tests
pkg/fileservice/index_cache_test.go: put/open/delete; invalid names; source errors and cancellation leave nothing; never visible before publication; evicted-while-open stays readable; restart reuse and temp/trash cleanup; two instances sharing a directory; concurrent put/open/delete/evict; one generation per open; incomplete entry repaired; move-in of a temp file; config split, default 0, resize split, path overlap rejected, invalid settings rejected; table-data cache ignores directory entries.pkg/vectorindex/indexfile: chunk assembly rules; manifest and names; per-file lock; rebuild then hit; tail-frame range with a caller verifier; missing, duplicate and corrupted chunks; corrupted cache entry rebuilt; no cache; concurrent misses rebuild once (fails without the lock); FDPath after eviction; Write naming, cleanup on failure and empty files; bounded verified set.pkg/sql/colexec/table_function,pkg/sql/plan: round trip through the real operator, lifecycle (Prepare/Call/Reset/Call/Free), argument and range checks, other transaction, expired token, internal-only planning.pkg/vm/engine/test/indexfile_test.go, against the real engine and SQL executor: write throughINSERT ... SELECT index_file_chunks; read back by SQL, by the writing transaction before commit, and by another cache after a flush with neighbouring rows the key-range filter must exclude; snapshot read after delete; duplicate key on rewrite; rows written by plainINSERT.cmd/mo-service: only a CN's SHARED file service gets the cache; default share creates none.-race, and the touched packages once under-race.🤖 Generated with Claude Code