Skip to content

fulltext2: read and write index files through the index-file layer; LRU index-file cache - #31773

Merged
XuPeng-SH merged 46 commits into
matrixorigin:mainfrom
cpegeric:index_io_fulltext
Nov 4, 2026
Merged

XuPeng-SH merged 46 commits into
matrixorigin:mainfrom
cpegeric:index_io_fulltext

Conversation

@cpegeric

@cpegeric cpegeric commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #31772

What this PR does / why we need it:

FULLTEXT2 used to stream every base segment and tail frame from its chunk rows into a temp
file on each load, so every CN restart re-read the whole index from the table. It now reads
and writes them through the index-file layer from #31050, which assembles each file once per
CN and keeps it in a local disk cache across loads and restarts.

FULLTEXT2

  • Base segments and tail frames larger than one chunk are index files. One-chunk tail frames
    stay plain chunk rows, written and read in batches.
  • Index files are read at the query's snapshot and account. Clone and restore carry them.

Index-file layer and cache

  • A rebuild scans only the file's chunk range by primary key.
  • A rebuilt file is verified while its chunks stream in, in any order: each chunk's CRC32-C
    is combined into the file's, so the file is never read back. Files recorded earlier with
    an MD5 are still verified by MD5.
  • The cache has its own capacity, separate from the table-data disk-capacity. It evicts
    least recently used first and never a file in use: a loaded index holds its files. Order
    of last use survives a restart.
  • A process has one cache per directory. CNs configured with the same directory (the
    multi-CN launch configs) share it, with the first CN's settings; CNs with different
    directories, such as CNs serving different partitions, have their own.
  • A background CDC tail write stages its files in the LOCAL spill directory.
  • Unused files are collected after an idle TTL (1h). When the disk drops below 10% free,
    unheld files are removed until 15% is free.
  • The table-data disk cache is unchanged and keeps S3-FIFO. That admission rule is wrong
    for index files: it evicted new generations ahead of stale ones and took three loads to
    settle.

Configuration ([fileservice.cache], CN only)

  • index-file-disk-capacity: default 8GiB; "0" turns the cache off.
  • index-file-check-on-startup: default false. When true, each cached file's full CRC is
    checked on its first open after a restart.
  • index-file-idle-ttl: default 1h.
  • index-file-disk-share is removed. It was added on main by index file I/O: a logical file layer and disk cache over index chunk tables #31050 and is not in any
    release tag; an old config that sets it still loads and the key is ignored.

pmc performance

Rally pmc, 574,199 documents (23.6 GB JSON). Single CN, Apple M2 Max (12 cores, 32 GB),
local SSD.

  • Index size: 13.0 GB in 461 index files, 12.1 GiB in the index-file cache.
  • LOAD DATA: 251 s. CREATE FULLTEXT2 INDEX: 292 s.
Cache 14GB (index fits) Cache 10GB (index does not fit)
First query after a restart 0.26 s 2.8–3.8 s (rebuilds the ~3 GB that does not fit)
First query, cache wiped (whole index rebuilt from rows) 24–28 s 23 s
Warm term top-10 3.5 ms 3.5 ms
Warm phrase top-10 3.8 ms 3.9 ms
Warm count physician 12.9 ms (43,392 rows) 12.8 ms (43,392 rows)
Warm count phrase 3.9 ms (141 rows) 3.9 ms (141 rows)
  • Warm queries run against the index loaded in memory, so the cache size does not affect
    them.
  • The first load after the capacity is lowered below the cached files takes longer (26.5 s
    going from 14GB to 10GB): files that load still needs are evicted to make room. Later
    restarts settle at the numbers above.
  • With 20GB of capacity the results are the same as 14GB (restart 0.25 s). A capacity just
    above the index size is enough.
  • How the cache-wiped first query came down within this PR:
    • on the 25% subset, 129 s with a full-table scan per file, then 9.25 s after the
      primary-key range scan;
    • on the full set, 38.8 s, then 24–28 s after streaming CRC32-C replaced the MD5
      read-back.
  • The restart first query went from 4.4 s to 0.26 s once the full check on startup became
    opt-in.
  • Before this PR, on the 25% subset (2.8 GB index, main-based build, 2026-10-21): the first
    query loaded the whole index from its rows, 8.2 s. With this PR's index files cached, it
    took 0.63 s, measured before the CRC32-C and startup-check changes.

cn.toml used for the 14GB runs:

[[fileservice]]
name = "LOCAL"
backend = "DISK-V2"
data-dir = "./mo-data/local2"

[[fileservice]]
name = "SHARED"
backend = "DISK-V2"
data-dir = "./mo-data/shared2"

[fileservice.cache]
index-file-disk-capacity = "14GB"

Size index-file-disk-capacity to hold the indexes the CN serves. Below that, each load
rebuilds the files that do not fit, about 1 s per GB on this machine.

Validation

  • Unit tests: pkg/fileservice/... (new lrucache, 100% coverage), pkg/vectorindex/indexfile,
    pkg/fulltext2/..., pkg/iscp, pkg/sql/colexec/table_function, cmd/mo-service,
    pkg/vm/engine/test.
  • Race: the cache's eviction, hold, reload, free-space and concurrency tests, 20 repeated
    -race runs each, plus one -race run of each package.
  • BVT: pessimistic_transaction/fulltext2 1037/1037 and fulltext2 1374/1374. New cases
    cover index files under CLONE, MERGE, DROP and snapshot RESTORE, and one-chunk tail frames.

Known limits

  • Separate CN processes sharing one cache directory (dynamic CN) each keep their own
    accounting and holds. Reads stay correct; the cost is extra rebuilds.
  • Design and decisions: docs/design/20261024-index-file-io.md.

🤖 Generated with Claude Code

cpegeric and others added 30 commits October 24, 2026 10:40
…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]>
An entry is a directory of named files published by one rename, opened through
one directory handle, and evicted or deleted as a unit (rename to trash, then
remove). Capacity, eviction, per-path coordination and restart reuse are those
of DiskCache; directory entries are enabled only on the index-file instance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The index-file cache takes index-file-disk-share (default 0.3) of
disk-capacity; the table-data disk cache keeps the rest, and a runtime
disk-cache resize is split the same way. Its directory defaults to
<disk-path>-index-file. index-file-rebuild-cache (read, none, read-write)
sets the cache policy for rebuilding an entry from its chunk rows. Only a
CN's SHARED file service gets the cache; GetIndexFileCache finds it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…their chunk rows

Open names a file by its storage table id, index_id, tag, chunk range, size
and checksum. A cache hit is checked against its manifest (full CRC32-C on
the first open in the process, length afterwards). A miss takes a per-file
lock, streams the chunk range through the relation readers of the caller's
transaction under the configured rebuild cache policy, requires every chunk
exactly once with its exact length, verifies the metadata checksum, and
moves the file into the cache. Without a cache the file is a private temp
file. IndexFileCache gains CreateTempFile and moving a local file into an
entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dex_file_chunks

Write keeps the file as one local file and registers it under a random
token bound to the writing transaction. Each internal statement
INSERT INTO <chunk table> SELECT ... FROM index_file_chunks(token, start,
count) writes at most 1000 chunks, so the insert pipeline keeps its
primary-key locks, duplicate check and composite key. The local file then
moves into the index-file cache. index_file_chunks is internal SQL only.

Open reads the caller's uncommitted rows up to the position a SQL SELECT
on the caller's process would: the whole workspace for borrowed SQL, the
statement boundary otherwise.

An engine test writes through the real pipeline and reads back through SQL,
the writing transaction, another cache after commit, an earlier snapshot,
and rows written by plain INSERT; rewriting existing chunks fails with a
duplicate key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
FDPath names the open descriptor (/dev/fd/N), so usearch View or the cuvs
tar unpacker can open a cached index file that the cache evicts meanwhile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- reject an index-file cache directory that overlaps the table-data disk
  cache, and clean disk-path before deriving the default (a trailing slash
  put it inside the table cache, whose restart scan deletes its files)
- Put replaces an existing entry that lacks a requested file, and syncs the
  entry directory before publishing it
- Open treats cache I/O errors as a miss and rebuilds; only cancellation
  fails; an invalid entry's verified mark is removed
- bound the verified set
- index_file_chunks: overflow-safe range check; fail closed when given an input
- FDPath documents the macOS shared-offset and after-Close behaviour
- tests: operator lifecycle and argument checks for index_file_chunks; Write
  naming, cleanup on failure and empty files; exact-multiple assembly; the
  engine test flushes rows, adds neighbouring rows the key-range filter must
  exclude, and asserts the cache hit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	docs/design/20261024-index-file-io.md
#	pkg/fileservice/cache.go
#	pkg/fileservice/index_cache.go
#	pkg/fileservice/index_cache_test.go
#	pkg/vectorindex/indexfile/assemble.go
#	pkg/vectorindex/indexfile/indexfile_test.go
#	pkg/vectorindex/indexfile/open.go
#	pkg/vectorindex/indexfile/ref.go
#	pkg/vectorindex/indexfile/write.go
#	pkg/vm/engine/test/indexfile_test.go
Base segments and CDC tail frames now go through pkg/vectorindex/indexfile:

- Base write (CREATE, MERGE, REBUILD): the segment's chunk rows are written
  with INSERT ... SELECT FROM index_file_chunks in the metadata row's
  transaction, replacing ChunkInserter; size and MD5 are cross-checked.
- Base read: the base is opened through the layer (index-file cache hit, or
  rebuilt and verified from its chunk rows) and mapped; the SQL chunk stream
  into a temp file is removed.
- Tail write (ISCP): each sealed frame is one index file from its starting
  chunk; every frame gets a metadata row (build_ts only when the column
  exists). The ISCP consumer supplies the engine and index-file cache.
- Tail read: loadTailFrames lists frames from their metadata rows and opens
  them through the layer; a tail with chunks no frame row accounts for
  (written before every frame had a row) is read from its chunk rows by
  legacyTailFrames, kept apart so it can be removed later.
- The index-file cache default share is 30%, set by this first adoption.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uery

A base or tail frame rebuilt from its chunk rows was read with the process's
current transaction and the caller's account, while its metadata row is read
by sqlexec at the query's named snapshot and execution account. On an
index-file cache miss, a MATCH on a named snapshot taken before MERGE failed
with "missing chunk" (the replaced base's rows are gone at the current
timestamp), and a subscribed table read the caller's account.

Reads now use the same target sqlexec does: the transaction cloned at the
historical named snapshot, and the account the internal SQL executes as.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every read through the index-file layer holds its cache entry; eviction or
deletion of a held entry waits for its last release. A loaded fulltext2 base
holds its file until it is freed. Entries with no holds unused for longer than
index-file-idle-ttl (default 1h, 0 disables) are deleted by a periodic
collection in each index-file cache.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A CDC tail frame that fits in one chunk is written without an index-file
cache entry, and all such frames are read in one scan of their chunk rows,
each checked against its frame metadata row. Larger frames are still read
and cached as index files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ole table

The chunk range filter passed its bounds as literals and the scan did not
read the primary key column, so the reader built no primary-key filter and
every file rebuild read the whole storage table: a cold load of pmc25
(111 files, 3 GB) took 129 s, now 9 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Index files now record a CRC32-C instead of an MD5. A rebuild computes
each chunk's CRC as it arrives, in any order, and combines them into the
file's, so the file is never read back; files recorded earlier with an
MD5 are still verified by MD5. The full check of a cached file on its
first open after a restart is now the index-file-check-on-startup cache
setting, off by default. pmc 100% (13GB index): first query after a
restart 4.4s -> 251ms, from an empty cache 38s -> 25.6s, CREATE INDEX
313s -> 292s.

Self-review fixes:
- Delete removes a held entry at once; holds defer only eviction and
  idle collection, and are counted per process across caches sharing a
  directory.
- One-chunk tail frames are inserted in batches again and read at most
  1000 per statement.
- Files rebuilt or written outside the cache go to the caller's temp dir
  (fulltext2: the LOCAL spill dir).
- The tail BVT waits on the stored frame count, not on MATCH.
- Design doc brought up to date.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The index-file cache now evicts least recently used first and never a
held file, through a new lrucache package with the methods and callbacks
of fifocache; the table-data cache keeps S3-FIFO. A new file is evicted
only after every older one that is not held, and entries reloaded after
a restart keep their order of last use. Holds are a plain in-use count.

Its capacity is the new index-file-disk-capacity setting (default 8GiB)
instead of a 30% share of disk-capacity, so the table-data cache keeps
its configured size; a runtime disk-cache resize applies to table data
only.

The idle GC also watches free disk space: below 10% free it removes
unheld files, least recently used first, until 15% is free, checking
every 30s while short.

pmc 100% (13GB index): restart first query 0.25s with 14GB or 20GB of
capacity; with 10GB, 2.8s, rebuilding only the 3GB that does not fit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Entries found on disk when the index-file cache loads are indexed
  behind every entry published or opened meanwhile, in their order of
  last use, and those removed meanwhile are skipped (new
  lrucache.SetOldest). An entry published again becomes the most
  recently used.
- Free-space collection decides by holds only, so it also removes files
  whose recorded last use is ahead of the clock.
- The private staging file of a write without the cache is unlinked at
  once, so a crash leaves nothing in the spill directory.
- Docs: an idle TTL of 0 turns off idle collection only; last use is
  recorded on disk at publication and the release of the last hold.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XuPeng-SH

XuPeng-SH commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 106ad04eec1d062e3f21a864aae948966cd967bc

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH 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.

mo-bot review · mo-bot-local · review

Commit: 106ad04eec1d062e3f21a864aae948966cd967bc

Assessment: request_changes

The staging-directory concern is resolved. The existing hold/eviction defect remains, and the revised cache design still lacks the required approval record.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

  • P2 pkg/fileservice/disk_cache.go:239: Capacity eviction observes dirHeld=false, then a concurrent reader acquires Hold and opens the files before eviction claims the path.
    Impact: Eviction removes the held entry and its accounting while open handles or mappings retain disk space. Subsequent opens rebuild another copy. Synchronize hold acquisition with eviction/removal, preserve accounting when a hold wins, and add the same-instance regression.
    Evidence: dirHeld releases held.mu before LRU removal; startEviction invalidates the reader generation; removeEvictedFile does not recheck holds. Reconciled exact-head probes reproduce held=true, LRU bytes=0 and ENOENT normally and under -race, with a passing preexisting-hold control. See reused/hold-probe.log, reused/hold-probe-race.log and reused-evidence-audit.json.

  • P2 docs/design/20261024-index-file-io.md:8: The PR materially changes eviction, shared ownership, capacity, collection and integrity policies beyond the cited approved revision fc9d8c0.
    Impact: The repository's required design gate remains open. Complete review of the revised decisions, close the hold/removal invariant, and record the reviewed revision and approval linked to #31773/#31772. No new RFC or particular human approver is required.
    Evidence: feature-design-review.md sections 1–2 require traceable approval for material design deviations. The document identifies only #31050/#31051 and explicitly leaves later decisions awaiting review. The complete frozen discussion contains no approval covering those revisions.

Validation:

  • Read the complete delta and assessed all nine discussion keys exactly once.

  • Reconciled ten retained receipts and logs against the exact head, 193 native inputs and seven native artifacts.

  • Reused passing fileservice, lrucache, fulltext2 and indexfile package tests; fileservice and lrucache also passed under -race. Recorded skips remain excluded.

  • Two new receipt-backed audits passed, including discussion coverage, retained evidence hashes, diff check and unchanged-source verification.

Limitations:

  • The deterministic reproduction uses scheduling barriers in a test-only overlay.

  • Dependent implementation acceptance stopped at the design gate. SQL/BVT and performance benchmarks were not rerun; detailed CI and benchmark logs were unavailable.

Eviction chose an entry when it had no hold, then removed it even if a
reader took a hold in between. The removal now checks the hold again under
the hold lock and moves the directory to trash under that lock; a held
entry stays on disk and goes back into the cache with its size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cpegeric

Copy link
Copy Markdown
Contributor Author

@XuPeng-SH mo-bot P2 pkg/fileservice/disk_cache.go:239 (a hold taken during eviction) is fixed in 50f752e.

  • Where the race is decided: removal of an evicted entry directory now checks the hold again under held.mu. It moves the directory to trash while still under that lock, the same way idle collection does, so held.mu decides between a hold and a removal.
  • If the hold wins: the directory stays and goes back into the LRU with its original size, so its bytes stay counted. This also covers an eviction left pending behind another path owner, which now carries its size.
  • If the removal wins: a later Open gets a clean not-found and the entry is rebuilt.
  • Explicit deletes are unchanged: Delete and idle collection remove the directory before they drop the LRU entry, so a held entry they removed is never put back.
  • Regression test: TestIndexFileCacheHoldWinsOverChosenEviction reproduces the race on one shared instance. It takes the hold right after eviction has chosen the entry, then checks that the entry is still on disk, still in the LRU and counted, and opens. After release, the entry is evicted normally and no temp or trash directories are left. The test fails with the new check disabled.

Validation:

  • The new test passes 100× under -race, and TestIndexFileCacheHoldDefersRemoval passes 50×.
  • pkg/fileservice/... passes normally, and pkg/fileservice plus lrucache pass under -race.
  • golangci-lint reports 0 issues.

The design-gate item stays open for @fengttt to approve the revised design.

🤖 Generated with Claude Code

@XuPeng-SH

XuPeng-SH commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 50f752e120b6e0f77d12edfb7210e471a96909e9

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH 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.

mo-bot review · mo-bot-local · review

Commit: 50f752e120b6e0f77d12edfb7210e471a96909e9

Assessment: request_changes

Current source addresses the earlier hold/eviction and CDC staging findings. The revised design still lacks required traceable approval.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

  • P2 docs/design/20261024-index-file-io.md:8: The feature materially changes eviction, shared-cache ownership, holds, default disk capacity, collection and integrity policies beyond the previously approved design.
    Impact: The repository’s mandatory design-first gate remains open. Record approval of the exact revised design and identify its owning issue #31772 and implementation PR #31773 before implementation acceptance.
    Evidence: .agents/skills/mo-dev/references/feature-design-review.md:64–94 requires traceable approval and renewed review of material deviations. The document records approval only for fc9d8c0/PR31050 and explicitly leaves later decisions awaiting review. Author comment 6527662639 confirms this existing gate remains open.

Validation:

  • Read the complete 41-file delta and all 12 discussion items; saved review-plan.md, review-notes.md and discussion-assessment.json.

  • Reconciled ten retained prior-head receipts and logs, including normal package and cache race passes; verified 193 native inputs and seven artifacts.

  • Current-head diff check, source integrity and discussion coverage checks passed. Receipts and logs are indexed in validation-ledger.json.

  • Frozen CI reports successful build, UT, SCA, proxy BVT and pessimistic multi-CN BVT.

Limitations:

  • No fresh Go tests, BVT or benchmarks were run. The latest hold fix was assessed through source and regression-test inspection.

  • Implementation acceptance stops at the design gate. Prior-head test passes and author-reported repetitions are not claimed as independently executed current-head validation.

@fengttt fengttt 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.

We don't have a cache replacement already? Even though it may not be LRU (or may)

Why do we need a new LRU cache? Is it because it is better (or, our code cache really sucked)? Do you have number support your decision to add LRU? And if it is the case, should we work on improving our cache in general instead of adding a new one?

@XuPeng-SH

XuPeng-SH commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 50f752e120b6e0f77d12edfb7210e471a96909e9

New discussion was assessed; the previous review remains unchanged.

@cpegeric

cpegeric commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@fengttt We do have one: the table-data disk cache uses S3-FIFO (fifocache). This PR doesn't change it or replace it. The new LRU applies only to the index-file cache, which is a separate instance with its own capacity. It is not a second general-purpose cache: lrucache is 280 lines with the same interface and callbacks as fifocache. The disk-cache code for publishing, trash and restart recovery is shared. Only the eviction policy differs.

Why not S3-FIFO for index files. S3-FIFO is built to keep one-pass scans from flushing hot data. A new entry goes into a small queue (10% of capacity) and is dropped unless it is read again while there. That is the right rule for table blocks. Index files are the opposite case: few, large (~27 MB each), written once by the build, then read on every load. S3-FIFO treats them as a scan to filter out.

Numbers with S3-FIFO (the first version of this PR used it): pmc 25% index, 3.05 GB in 111 files, cache 2.58 GB:

  • The build wrote all 111 files, but only ~9 survived in the small queue. The rest were evicted as ghosts.
  • First query after the build rebuilt 103 of 111 files: 9.2 s.
  • It only settled after several restarts, as ghost re-inserts moved files into main: 9.2 s → 4.6 s → 3.3 s.
  • Files from replaced index generations sat in main while the new generation was evicted from the small queue.
  • S3-FIFO also evicts a file that a loaded index is still using. The file stays on disk but leaves the accounting, so disk use can go past capacity.

With LRU (held files never evicted), pmc 100%, 13 GB index:

  • Index fits (14 GB capacity): first query after restart 0.26 s.
  • Index doesn't fit (10 GB capacity): it settles after one load at 2.8–3.8 s. Only the ~3 GB that doesn't fit is rebuilt, and disk use stays at 10 GB.

Why not change the general cache instead. The table-data workload (many small blocks, long scans) is what S3-FIFO's admission rule is for. Changing that policy for everyone to suit index files would risk table-scan regressions to fix a problem table data doesn't have. Keeping the caches separate also means a big index load can't evict hot table blocks, and the reverse.

The reasoning is recorded in the design doc under "Eviction: least recently used, never a held file", including the rejected S3-FIFO alternative.

@XuPeng-SH

XuPeng-SH commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 50f752e120b6e0f77d12edfb7210e471a96909e9

New discussion was assessed; the previous review remains unchanged.

@cpegeric

cpegeric commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@LeftHandCold @aptend @fengttt Please kindly re-review it. thanks

# Conflicts:
#	pkg/fileservice/disk_cache.go
@XuPeng-SH

XuPeng-SH commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 039c69973b2d62a9c2c3787eece84bc653c8bbb1

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH 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.

mo-bot review · mo-bot-local · review

Commit: 039c69973b2d62a9c2c3787eece84bc653c8bbb1

Assessment: request_changes

The LRU specialization reuses DiskCache and has a credible workload rationale. Current source addresses the earlier hold and staging concerns, but the required revised-design review remains open.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

  • P2 docs/design/20261024-index-file-io.md:8: The feature materially changes eviction, shared lifetime, default capacity, collection and integrity policies beyond the recorded fc9d8c0 approval.
    Impact: The repository’s design-first gate remains unmet. Complete the pending design review and record the exact revised approval for #31772/#31773 before implementation acceptance.
    Evidence: feature-design-review.md:66–89 requires traceable approval of material deviations. The document still marks later decisions awaiting review. Comment 6527662639 explicitly retains the gate; review 5731447110 requests changes. The substantive reply 6571878409 supplies rationale, but no subsequent approval appears in the complete discussion.

Validation:

  • Read all 41 file deltas and assessed all 19 discussion entries.

  • Source integrity, diff whitespace and discussion coverage passed: checks/1793703508957254356-2.json; source-audit.log. Receipts reconciled in validation-index.json.

  • Current source and regression oracles support resolution of the earlier hold/eviction and CDC staging findings. Frozen CI reports successful build, UT, SCA and BVT checks.

Limitations:

  • Full independent implementation acceptance stopped at the design gate, including remaining concurrency, transaction/snapshot and performance validation.

  • No fresh Go, race, BVT or benchmark runs; prior probes and detailed author/CI logs were unavailable.

@XuPeng-SH

XuPeng-SH commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: e5ab3124fb6b674d1774203c165d4121a328c70e

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH 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.

mo-bot review · mo-bot-local · review

Commit: e5ab3124fb6b674d1774203c165d4121a328c70e

Assessment: approve

The revised-design approval closes the prior gate. Earlier hold/eviction and CDC staging concerns are resolved. FULLTEXT2 coherently reuses the index-file and DiskCache owners; the dedicated LRU supports large index files while preserving table-data S3-FIFO. No actionable findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Reviewed all 41 changed files, relevant owners/consumers, linked issue and all 22 discussion entries; saved discussion-assessment.json.

  • Isolation preflight passed. All five LRU tests passed normally and with the race detector using Go 1.27.1 and the supplied test executor.

  • The isolated CRC source probe passed seven size cases against the standard-library checksum oracle.

  • Frozen CI metadata reports 14 successful, 14 skipped and 2 neutral contexts; skipped/neutral contexts were not counted as passes.

  • Source/evidence audit and receipt reconciliation passed. Commands, source fingerprints, exits and retained logs match; source remains unchanged. Records: validation-evidence.md and receipt-reconciliation.json.

Limitations:

  • Full native-package suites, SQL/BVT and benchmarks were not rerun locally; native prerequisites are absent.

  • Raw CI and author execution logs were unavailable; broader test and performance reports remain qualified.

  • Documented independent cache accounting across separate processes remains an accepted limitation.

@aunjgr aunjgr 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.

Code review at 621985b: no blocking code finding.

I reviewed the changed production paths for shared cache ownership, LRU/hold/idle-GC coordination, persisted restart ordering, CRC assembly and legacy MD5 reads, snapshot/account targeting, FULLTEXT2 mmap ownership, and small/large/legacy tail-frame handling. The layer keeps chunk rows transactional, transfers the cache hold to the mapped base until Free, and retains the legacy tail scan when frame metadata does not cover all chunks. The added tests exercise the important eviction/hold races, invalid held-entry replacement, bounded small-frame scans, and snapshot/clone/restore behavior.

Local validation on this exact head: go test -race ./pkg/fileservice/lrucache -count=1 passed. I reused the exact-head successful build, SCA, coverage and BVT runs as additional evidence; I did not rerun the full kernel suite locally.

CI is NOT all green: UT job 126462047964 in run 41796558700 failed in TestIssue28317DisjointDDLAndTenantRestore (PITR restore context deadline exceeded) and TestIssue29133RoleRulesTrackRemoteChanges (bad/closed connection). I inspected those logs but have not proven the failures pre-existing or unrelated. This approval is the code-review verdict, not a claim that CI passed; the failed required checks still need resolution before merge.

@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request dequeued

3 h 8 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Wed 4 Nov, 13:17 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 16:25 · 8ffb370

Reason

Pull request #31773 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.

The author needs to enable "Allow edits from maintainers" on this pull request.

To get back in the queue

  • Push a change if one is needed: the pull request is queued again once its queue conditions match.
  • If no change is needed, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 8ffb3707 Deployed Nov 4, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/enhancement kind/feature size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants