Repository navigation
FIX: FileService implements new DISK-V2 backend to replace DISK - #25272
Conversation
LocalFS (backend "DISK") frames every file as [crc32 4B][2044B content] blocks, so its on-disk layout differs from the S3 (disk-backed) file service, which stores raw bytes. Add a new backend "DISK-V2" that stores raw bytes, making the local format byte-identical to S3FS-on-disk and dropping the per-2KB CRC cost. DISK-V2 is OPT-IN. The cluster-wide default stays "DISK" (the Go embedded defaults in cmd/mo-service/config.go and pkg/embed/config.go are unchanged), so existing data dirs and any deployment still on the old config keep reading their CRC-framed data unchanged. The shipped launch configs under etc/launch* opt into DISK-V2 explicitly by setting backend = "DISK-V2" on their LOCAL/SHARED disk fileservices (S3/MINIO/ETL/TMP services are left as-is). Default-injection only fills in a service the toml omits, so an explicit toml block always wins. Implementation: - FileWithChecksum gains a noChecksum passthrough mode: ReadAt/WriteAt delegate straight to the underlying *os.File, Seek uses contentSize=fileSize, and contentOffsetToBlockOffset is identity. Read/Write still route through ReadAt/WriteAt on contentOffset so the read path can share one fd across IOVector entries. New raw constructors NewFileWithout[Checksum]OSFile. - LocalFS gains a noChecksum field + NewLocalFS2; the 7 wrapper sites route through helpers and List/StatFile size math through contentSize(). - config.go registers backend "DISK-V2" -> NewLocalFS2. Formats are not interchangeable and have no magic/header: pointing DISK-V2 at a DISK data dir fails loudly (parse error on the leading CRC bytes), and DISK at a DISK-V2 dir fails with "checksum not match". There is no in-place migration, so a populated dir must keep the backend it was written with. Offline readers (objecttool, checkpointtool, backup, objectio.NewOfflineFS) stay on DISK and read their fileservice in code (not via the launch toml); making them format-aware needs a backend flag and is left as follow-up. Measured (M2 Max, 24 MiB): reads ~1.9x faster (5.4 -> 10.4 GB/s), writes ~14x faster (0.53 -> 7.5 GB/s, 12313 -> 0 allocs/op). Verified single-node and multi-CN clusters bootstrap, write/read, and run ivfflat on DISK-V2. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… --local2 The offline readers could only read one on-disk format each, so they failed on data written by a different fileservice. Unify both offline tools on a single format selector with three mutually-exclusive flags: --local local LocalFS, legacy DISK (CRC32-framed) [default] --local2 local LocalFS, DISK-V2 (raw, checksum-free) --s3 S3FS over a local disk endpoint (raw, S3FS-on-disk layout) objectio.NewOfflineFS now takes a kind string (local/local2/s3) instead of the old fromS3 bool, with an OfflineKind(local, s3, local2, default) resolver and OfflineKind* constants. Both tools route through it: - TAE inspect tool (pkg/vm/engine/tae/rpc/tool.go): the object stat/get and storage ckp stat/list commands gain --local2 (and the previously-missing --s3/--local), preserving each command's prior default. - mo-object-tool object/view/info and ckp: replace the interim --backend flag with --local/--s3/--local2; objecttool.OpenWithKind and checkpointtool.WithKind thread the kind (incl. nested object drill-down via ViewOptions.Kind). This supersedes the earlier hardcoded --backend approach: --local2 is the clean LocalFS reader for DISK-V2 data (same rootPath layout, just raw), while --s3 keeps the S3FS-on-disk path. Default stays local (CRC), so existing fixtures, data, and tests are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A filesystem backup created its destination LocalFS via GetForBackup, which hardcoded the legacy DISK (CRC32-framed) format. On a DISK-V2 (raw) cluster the archive was therefore CRC-framed while restore reads it in the cluster's raw format — so restore would fail on the unexpected CRC bytes. Derive the archive format from the cluster's data fileservice (cfg.SharedFs, the backup's read source, configured by the .toml) so the archive always matches: - fileservice.LocalBackendOf(fs) reports the LocalFS backend whose framing matches fs — "DISK" only for a checksummed LocalFS, "DISK-V2" for raw services (DISK-V2 LocalFS, S3FS, ...). - GetForBackup(ctx, spec, backend) selects NewLocalFS (CRC) vs NewLocalFS2 (raw) for the local case; backend is ignored for argumented (s3-opts) specs. - backup.Backup threads LocalBackendOf(cfg.SharedFs) through setupFilesystem. The .toml stays the single source of truth: SharedFs is its materialization, and the backup now follows it. S3 backup targets are unaffected (already raw). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The three on-disk formats are mutually incompatible and cannot be auto-detected,
so a silent default would misread half the time and fail with a cryptic error
("load meta: EOF" / "checksum not match"). Instead, the offline inspection tools
now require the operator to state the format: exactly one of --local (DISK/CRC),
--s3 (S3-on-disk/raw) or --local2 (DISK-V2/raw). Zero or more-than-one is a clear
error.
objectio.OfflineKindStrict replaces the defaulting resolver. Applies to
mo-object-tool (object/view/info, ckp) and the TAE inspect tool (object stat/get,
storage ckp stat/list). The programmatic objecttool.Open and test fixtures keep
the local (DISK) default, so existing tests are unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Fills the coverage gaps for the DISK-V2 work surfaced by review: - hashjoin: TestHashJoinSpillDiskV2 runs the build-bucket spill + rebuild round-trip with a NewLocalFS2-backed LOCAL fileservice, confirming spill works when the cluster is configured DISK-V2 (spill uses MutableFileService.CreateFile -> a raw *os.File, so it is format-agnostic, but this verifies the wiring). - checkpointtool: TestOpenWithKind exercises WithKind(local/local2) + Kind() (the package previously had no tests). - file_with_checksum: TestFileWithoutChecksum now also covers append (WriteAt at EOF extends the file 1:1) and Seek(SeekEnd) tracking the new size in raw mode. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
tmpNewFileservice (behind TmpNewFileservice / TmpNewSharedFileservice and the TAE options.FillDefaults nil-fileservice fallback) hardcoded backend "DISK". Flip it to "DISK-V2" so the fallback matches the default cluster data format. This path is only reached when TAE options are built WITHOUT a configured fileservice — i.e. tests and standalone/dev TAE instantiation over a fresh temp dir. A real cluster always injects its .toml-driven fileservices (tnservice/factory.go sets opt.Fs/opt.LocalFs from the SHARED/LOCAL services), so production never hits this fallback. The temp fileservices round-trip their own fresh data, so the format choice is otherwise immaterial. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
I think this needs changes before merging. The implementation direction is reasonable, but the compatibility boundary is not strong enough for a storage-format change.
Main concern: the existing launch profiles are changed to backend = "DISK-V2" while still pointing at the same ./mo-data/local and ./mo-data/shared paths. DISK and DISK-V2 have no magic/header, and the new test explicitly documents that a raw DISK-V2 reader over legacy DISK bytes can return wrong raw bytes at the fileservice layer. That means a normal developer/operator flow of upgrading the binary and reusing the same launch command/data dir can select the new format against old data without a startup-time format guard. Please make the boundary first-class: either keep existing etc/launch* profiles on DISK and add separate fresh-deploy DISK-V2 profiles/data dirs, or add an on-disk format marker/fail-fast validation before DISK-V2 opens a non-empty dir. A comment saying “fresh deployment” is not enough protection for a format-incompatible backend.
The compatibility mechanism in this PR is config-level dual backend plus etc/v1, not MatrixOne's formal pkg/bootstrap/versions upgrade framework. That can be acceptable because this is file layout rather than catalog metadata, but then the config/tooling compatibility path has to be complete and tested. Right now cmd/mo-service/toml_fileservice_test.go scans etc/launch* but not the new etc/v1/** tree, even though etc/v1 is the proposed legacy compatibility path. Please include the etc/v1 configs in the parse/backend-string coverage.
Also git diff --check origin/main...HEAD fails on the new etc/v1 files due trailing whitespace / blank lines at EOF. Please fix that before merge.
Docs need to be updated as part of the same change. etc/DEV_README.md still describes these local launch methods as DISK backend and its data directory compatibility section does not mention DISK vs DISK-V2 or how to run old data after upgrade. Since this PR changes shipped launch defaults, the migration/compatibility guidance should be explicit.
The targeted tests I ran locally pass with the proper CGo include/lib paths: pkg/fileservice, cmd/mo-object-tool, cmd/mo-object-tool/ckp, cmd/mo-service, pkg/tools/objecttool/interactive, pkg/tools/checkpointtool, and pkg/sql/colexec/hashjoin. The remaining blocker is the compatibility guard/process, not the basic raw-mode implementation.
…mpat coverage Address review: the DISK-V2 launch profiles pointed at the same ./mo-data/local and ./mo-data/shared paths as legacy DISK data. Since DISK and DISK-V2 have no on-disk magic/header and are not interchangeable, upgrading the binary and reusing the same launch command could open the raw DISK-V2 reader over legacy DISK bytes. Boundary: give DISK-V2 its own data dirs so it never collides with legacy DISK. - Every DISK-V2 LOCAL/SHARED service in etc/launch* now uses mo-data/local2 / mo-data/shared2. For LOCAL blocks that had no data-dir (which defaulted to ./mo-data/local via defaultFileServiceDataDir and thus collided), insert an explicit data-dir = "mo-data/local2". etc/v1/** stays on DISK at local/shared. - Non-local/shared DISK-V2 dirs (minio-local, tae-compose) are config- or container-scoped and don't collide, so they're unchanged. Tests: extend cmd/mo-service/toml_fileservice_test.go to scan the etc/v1/** tree in both the parse and backend-string checks (the legacy compat path was uncovered). Whitespace: strip trailing whitespace + EOF blank lines in the flagged etc/v1 files (git diff --check clean). Docs: etc/DEV_README.md relabels Method 1 as DISK-V2 and adds a "DISK vs DISK-V2 storage format (after upgrading)" section with the backend -> config-tree -> data-dir table and the etc/v1 command to run old DISK data. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
DISK-V2 stores objects as raw bytes with no per-2KB-block CRC framing, so a legacy DISK (CRC-framed) file opened through the raw DISK-V2 reader — or header corruption — would previously be returned as valid-looking garbage. ReadHeader now validates the object magic (0xFFFFFFFF, stable since 2022) in the first 8 bytes it already reads at offset 0, and errors "bad header magic" on a mismatch instead of proceeding. This is a zero-extra-IO self-check on every object meta load, catching a DISK/DISK-V2 format mismatch (the reviewer's boundary concern) at the read layer. It does not detect mid-object bit-rot; the dead ColumnMeta/Footer checksum fields are left for a separate CRC PR. - add Header.Magic() accessor (meta.go) - guard in ReadHeader (reader.go) - TestReadHeaderMagic: accessor + reject-branch coverage (magic_test.go) - fix stale "default is DISK" comment in mo-object-tool (strict flag required) Verified: pkg/objectio suite green; live SQL round-trip on both DISK and DISK-V2 (write -> flush -> read-back) returns correct data with no magic errors. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Review — Multi-angle analysis (First Principles + Unhappy Path)Unhappy Path🔴 Startup-time format validation is missing
The subsequent commit separating data dirs ( Suggestion: On opening a non-empty directory in 🔴
|
| Missing test | Why it matters |
|---|---|
Upgrade E2E: old DISK data → launch with etc/v1 → read succeeds |
Closes the validation loop for the entire migration strategy |
| Mixed directory: same dir contains both DISK and DISK-V2 files | Current behavior is undefined |
Concurrent WriteAt to the same file at different offsets |
os.File.WriteAt is thread-safe, but FileWithChecksum has an internal contentOffset field — needs a test to confirm passthrough mode does not touch it |
Code Quality
🟡 LocalBackendOf fallback lacks an explanatory comment
func LocalBackendOf(fs FileService) string {
if lfs, ok := fs.(*LocalFS); ok && !lfs.noChecksum {
return diskFileServiceBackend
}
return diskV2FileServiceBackend // MemoryFS, S3FS, ErrorFS all fall through here
}All non-*LocalFS types return DISK-V2. This is intentional (they are all raw formats), but without a comment the next reader will be puzzled.
Testing & Performance
🟡 Benchmark methodology
The benchmark uses 24 MiB sequential read/write. Real workloads are typically small-block random reads (4 KB–64 KB) with mixed read/write and cache hit/miss patterns. Sequential benchmarks alone cannot fully support the performance claims.
Suggestion: Supplement with random small-block I/O benchmarks to give a more complete performance picture.
Summary
| Priority | Issue |
|---|---|
| 🔴 | No startup-time format validation when NewLocalFS2 opens a non-empty dir |
| 🔴 | tmpNewFileservice silently switches to DISK-V2 without guard |
| 🟡 | Missing upgrade E2E / mixed-dir / concurrent-write tests |
| 🟡 | OfflineKindStrict error message conflates n==0 and n>1 |
| 🟡 | Benchmark only covers sequential I/O |
| 🟢 | LocalBackendOf fallback needs a comment |
…ndependent Review follow-ups: - NewOfflineFS previously fell through `default` to the legacy DISK format for any unrecognized kind. Since DISK and DISK-V2 are mutually incompatible and can silently misread, a typo passed via OpenWithKind/WithKind now fails with "unknown offline fs kind" instead of defaulting. OfflineKindLocal is an explicit case; only known kinds construct a fileservice. (+ TestNewOfflineFSKind) - TestCkpInfoEmptyDir invoked setupLogFile, which writes $HOME/.mo-tool/ckp.log; point HOME at t.TempDir() so it doesn't depend on / pollute the real home and passes in a read-only-home sandbox. (The stale "default is DISK" comment in object.go was already corrected in the prior commit.) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ent-writeat test - OfflineKindStrict: split the n==0 (none) vs n>1 (conflicting) cases into distinct messages instead of one "specify exactly one" for both — the none-set case is not a user error of over-specifying. - LocalBackendOf: comment why every non-CRC-LocalFS service (DISK-V2 LocalFS, S3FS, MemoryFS, ErrorFS, …) maps to the raw DISK-V2 backend. - Add TestFileWithoutChecksumConcurrentWriteAt (passes under -race): concurrent WriteAt at distinct offsets through one shared passthrough wrapper round-trips correctly, confirming passthrough WriteAt never touches contentOffset. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
tmpNewFileservice silently builds a raw DISK-V2 fileservice as a fallback for tests / standalone TAE that don't inject a .toml-configured fileservice. If a production path ever misses the injection it would write DISK-V2 format where DISK is expected, with no signal. Add a logutil.Warn so a missed injection is surfaced rather than silent. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A raw (DISK-V2) LocalFS pointed at a directory that already holds legacy DISK (CRC32-framed) data would silently return wrong bytes (raw reads over framed bytes). newLocalFS now runs a best-effort startup guard (checkNotCRCFramed) for DISK-V2: it scans the first regular file and errors if that file is CRC-framed (first 4 bytes are a valid crc32-Castagnoli of the rest of the block), pointing the operator at the DISK backend. This lives at the fileservice layer (it can't import objectio for the object magic without a cycle, and it owns the CRC format), and surfaces as a startup failure because newLocalFS runs during createFileService. - empty dir (fresh deploy) passes; false-positive on raw data is ~1/2^32 - update TestLocalFSFormatsAreIncompatible: DISK-V2-over-DISK now fails at construction instead of silently misreading - add TestLocalFS2FormatGuard (empty / raw-ok / framed-rejected) Verified live: DISK-V2 boot + create/flush + restart reads real objects back correctly (guard does not false-reject); DISK data opened as DISK-V2 is rejected. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Several etc/v1 legacy configs (and their etc/launch counterparts) ended without a final newline, which GitHub flags with the "no newline at end of file" marker. git diff --check does not catch missing-final-newline (only trailing whitespace / blank-at-EOF), so these slipped past the earlier whitespace fix. Append a single trailing newline; no content change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…eak) The DISK-V2 format guard ran after initCaches, which had already started the mem/disk-cache eviction goroutines and opened the disk-cache directory fd. On the guard's error path newLocalFS returned nil,err without closing them, leaking goroutines + an fd per failed construction — unbounded for a caller that keeps running (e.g. repeated dynamic LocalFS2 creation). Move the guard before initCaches. It only reads a file (no cache needed), so a failed guard now starts nothing to leak. Behavior is otherwise unchanged; TestLocalFS2FormatGuard / TestLocalFSFormatsAreIncompatible still pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
aunjgr
left a comment
There was a problem hiding this comment.
Storage format change with no startup detection. Launch defaults switch to DISK-V2 on old data dirs — silent corruption. Either add a format marker with fail-fast on mismatch, or keep existing profiles on DISK and gate DISK-V2 behind fresh data dirs. etc/v1 backward-compat configs are the right idea but the default must stay safe.
We already have a fail fast check and new data-dir is in new directory. Most importantly, we will completely remove DISK after a few month. DISK is buggy and should be removed eventually. |
fixed. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
I still see two substantive compatibility blockers here.
- Several shipped DISK-V2 launch configs still reuse the old DISK data directories.
The current head does have a startup-time guard in NewLocalFS2, but the config side is still inconsistent with the README’s upgrade-safety claim. A number of shipped DISK-V2 launch targets still point LOCAL / SHARED at the same old paths that legacy DISK deployments already use:
etc/launch-minio-local/{cn,log,tn}.tomlstill use./etc/launch-minio-local/mo-dataetc/launch-tae-compose/config/{cn-0,cn-1,log,tn}.tomlstill use/var/lib/matrixone/dataetc/docker-multi-cn-local-disk/generate-config.shstill emitsSHARED=/mo-data/shared, andLOCALstill falls back under the old default data-dir logic
That means "upgrade the binary and rerun the same launch command" is not actually safe for those shipped configs, even though etc/DEV_README.md now claims all etc/launch* configs have moved to fresh local2/shared2 directories.
Suggested fix: either move every shipped DISK-V2 config to fresh directories (matching the README), or keep those configs on legacy DISK. The docs should only claim upgrade safety once the shipped configs actually satisfy it.
- The standalone/embedded TAE default-open path still silently switches existing databases to DISK-V2.
DB.Open() still calls opts.FillDefaults(dirname) when Fs / LocalFs are missing, and that fallback still goes through objectio.TmpNewFileservice(..., path.Join(dirname, "data")) with backend DISK-V2. Because DISK-V2 now rejects legacy DISK directories at open time, any standalone/embedded TAE caller that relied on the old default fallback can no longer reopen an existing database after upgrade.
The new warning in tmpNewFileservice is helpful, but it does not remove the compatibility break on that default open path.
Suggested fix: preserve legacy DISK for this fallback path, or make the fallback format explicit/configurable and default to compatibility when reopening existing standalone data. At minimum, DB.Open() should not silently change its default on-disk format for existing callers.
|
Here's my answer above restated with the original names:
The fileservice.Get[...] checks (config.go:364/370, embed:342) are a safety-net validator that only trips if fill somehow didn't run. Real
So their "DISK-V2 at the old dir" (instead of a fresh local2/shared2) cannot hit the reject in CI, because no CI reopens pre-existing DISK data Conclusion: tmpNewFileservice (and its TmpNewFileservice/TmpNewSharedFileservice wrappers) is 100% test-only, tests run on fresh dirs, so the current DISK-V2 backend is already safe — no change strictly required. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
I still think this needs changes.
-
The launch-profile migration is still not compatibility-safe for all shipped/dev configs.
etc/DEV_README.mdnow says alletc/launch*profiles use freshlocal2/shared2dirs and that re-running the same launch command after upgrade is safe (etc/DEV_README.md:373-390). But several profiles still only flip the backend toDISK-V2while keeping the old legacy-DISK data path. For example:etc/launch-minio-local/cn.toml:9-12keepsdata-dir = "./etc/launch-minio-local/mo-data"etc/launch-tae-compose/config/cn-0.toml:8-11keepsdata-dir = "/var/lib/matrixone/data"
Those are the same paths these profiles previously used with
DISK, so re-running the existing profile after upgrade still repoints a rawDISK-V2backend at CRC-framed legacy bytes. That contradicts the new README safety claim and keeps the migration hazard alive for those shipped configs. -
The standalone / embedded default still changes under callers that do not inject a fileservice. The PR body says the cluster default stays
DISKand Go embedded defaults stay unchanged, buttmpNewFileservicenow unconditionally falls back toDISK-V2(pkg/objectio/fs.go:75-94), andOptions.FillDefaultsstill uses that fallback whenevero.Fs/o.LocalFsare nil (pkg/vm/engine/tae/options/options.go:285-290). Sodb.Open(..., nil)/ other standalone TAE callers that previously reopened legacy local data through the implicitDISKpath now switch toDISK-V2instead. The new CRC guard may make that fail loudly instead of silently misreading, but it is still a compatibility break in the default-open path.
I think those two compatibility gaps need to be closed before merge: either keep the unchanged profiles on legacy DISK (or move them to fresh dirs too), and either preserve the old standalone fallback backend or make the changed default explicit rather than silently flipping it.
What type of PR is this?
Which issue(s) this PR fixes:
issue #25040
What this PR does / why we need it:
DISK-V2: a checksum-free local fileservice format
Why
LocalFS (backend DISK) frames every file as [crc32 4B][2044B content] blocks, so its on-disk layout differs from the S3 file service (including
its disk-backed endpoint="disk" variant), which stores raw bytes. This asymmetry means a file written by LocalFS is not byte-identical to the
same file written by S3FS-on-disk. This PR removes that CRC/block framing from the local path via a new backend, DISK-V2, whose on-disk format
is byte-identical to S3FS-on-disk.
What's added
New backend DISK-V2 (opt-in).
size, and offset mapping is identity. CRC framing is skipped entirely.
clusters. Old data dirs keep working on DISK with no migration.
Backward-compatibility note. The two formats share no magic/header and are not interchangeable on the same data dir: pointing DISK-V2 at DISK
data fails loudly (parse error on the leading CRC bytes), and DISK at DISK-V2 data fails with checksum not match. The format is fully
encapsulated in LocalFS/FileWithChecksum; all startup/runtime paths read through the fileservice and are format-agnostic, so a cluster can be
configured as either backend and works with its own data.
Offline tools are format-aware and require an explicit choice.
since a wrong guess gives a cryptic error).
Backup follows the cluster's format (single source of truth). A filesystem backup's archive is created in the same on-disk format as the
cluster's data service (cfg.SharedFs, configured by the .toml) via fileservice.LocalBackendOf, so restore reads it in the cluster's format.
DISK-V2 cluster → raw archive; legacy DISK cluster → CRC archive. S3 backup targets are unaffected (already raw).
Misc. tmpNewFileservice (the TAE FillDefaults nil-fileservice fallback, only hit by tests/standalone instantiation — production always injects
the configured fileservices) now defaults to DISK-V2.
Performance
Isolated fileservice benchmark (M2 Max, 24 MiB): reads ~1.9× faster (5.4 → 10.4 GB/s), writes ~14× faster (0.53 → 7.5 GB/s, 12,313 → 0
allocs/op).
Testing
OfflineKindStrict, LocalBackendOf/GetForBackup, checkpointtool.WithKind, and join-spill on a DISK-V2 LOCAL fileservice.
"DISK"; and the CLI was verified on a real DISK-V2 object — --local2/--s3 read it, --local fails with checksum not match, no-flag errors
clearly.
Commits