Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
No matching issue was found for setAutomaticSpillDiskCapFromAvailable or the stale filesystem-sample / concurrent spill-release mechanism. Related #29755 concerns writeback overhead, and #30097/#30100/#30103 concern cleanup ownership after file-removal failures; neither mechanism is required here.
Branch Name
main
Commit ID
- Inspected current main:
76deafc8062f9a7e33a31a4df858ebcdb9477cb5. - Actual native package-test revision:
bd9c69f8fcff893bc23c029149f8d915cef11191(an existing clean main checkout with matching native artifacts). - The entire
pkg/vm/process/execution_resource_budget.gofile is byte-identical at the tested revision, inspected current main, and the nightly revisione8b3ed7f21c2b1966d74814adaa2bcd96d8c129f: SHA2560d5841061449c4bd87ba04562185908c14b595926639fbbe25425e1ad1b70604. The filesystem-sampling helper is also identical.
Other Environment Information
- Linux/amd64, repository-supported CGo test wrapper;
GOMAXPROCS=4, build parallelism 2. - No production changes. A Go test overlay adds only the diagnostic test below to the real
pkg/vm/processpackage. - This is a deterministic component reproduction of a permitted concurrency interleaving. Filesystem availability is supplied explicitly; the test does not allocate hundreds of GiB, perform real filesystem I/O, or claim to replay the entire BigData workload.
Actual Behavior
A filesystem sample taken before another statement releases its spill is combined with the ledger after that release. This can mistake the statement's own released storage for external disk consumption, permanently shrink the live CN spill envelope, and reject a reservation that fits the unchanged capacity.
GetExecutionResourceBudget obtains automaticDiskAvailable before loading/locking the shared CN budget. setAutomaticSpillDiskCapFromAvailable later locks that budget and adds its current spillDiskUsed to the older sample. There is no sample/ledger generation check. A concurrent statement can remove files and release reservations between those operations.
Deterministic example, with no external disk growth:
| Step | Actual free space | Live spill ledger | Effective CN spill cap |
|---|---|---|---|
| Initial automatic policy | 256 GiB | 0 | 192 GiB |
| A owns 100 GiB, B owns 28 GiB | 128 GiB | 128 GiB | 192 GiB |
| C samples available space | sample = 128 GiB | 128 GiB | 192 GiB |
| A removes its file and releases 100 GiB | 228 GiB | 28 GiB | 192 GiB |
| C publishes its stale sample | 228 GiB | 28 GiB | 117 GiB |
| A subsequent refresh samples the correct 228 GiB | 228 GiB | 28 GiB | still 117 GiB |
| B requests another 100 GiB | 228 GiB before allocation | requested total = 128 GiB | rejected |
The incorrect reconstruction is (128 + 28) * 3/4 = 117 GiB; a coherent snapshot reconstructs (228 + 28) * 3/4 = 192 GiB. The later fresh sample cannot restore the original envelope because the implementation prohibits raising an automatic cap while any spill remains live.
Actual test output:
fresh_sample_control:
cap_after_publish=192GiB cap_after_fresh=192GiB grow100=<nil>
release_between_sample_and_publish:
cap_after_publish=117GiB cap_after_fresh=117GiB
grow100=internal error: execution resource admission rejected:
requested=107374182400 used=30064771072 cap=125627793408
--- PASS: .../fresh_sample_control
--- FAIL: .../release_between_sample_and_publish
FAIL github.com/matrixorigin/matrixone/pkg/vm/process 0.030s
The failure is the diagnostic invariant assertion, not a compilation/native-link error. This is a logical snapshot race, not necessarily a Go data race.
Expected Behavior
Releasing owned spill, without any external filesystem consumption, must not be interpreted as a reduction in the original automatic spill envelope. A refresh must use a coherent filesystem/ownership observation or reject/retry an obsolete sample before it can irreversibly tighten a live budget.
Preserve finite shared/query limits, real filesystem safety headroom, explicit operator limits, and correct rejection under genuine external storage pressure. This report does not recommend disabling admission or allowing arbitrary cap growth.
Steps to Reproduce
Add the following test to pkg/vm/process at the revision above and run it with the repository's native test wrapper. The serial sequence deliberately schedules the allowed gap between automaticSpillDiskAvailable() and publication; it requires no sleeps or race-luck.
package process
import "testing"
func TestSpillSnapshotReleaseInterleaving(t *testing.T) {
const GiB = uint64(1 << 30)
for _, stale := range []bool{false, true} {
name := "fresh_sample_control"
if stale { name = "release_between_sample_and_publish" }
t.Run(name, func(t *testing.T) {
b := MustNewExecutionResourceBudget(1024, 1024)
defer b.Close()
must := func(err error) {
t.Helper()
if err != nil { t.Fatal(err) }
}
must(b.setAutomaticSpillDiskCapFromAvailable(256 * GiB))
a, err := b.openProcessGeneration(1, 1024, 0)
must(err)
defer a.Close()
live, err := b.openProcessGeneration(2, 1024, 0)
must(err)
defer live.Close()
releasedFile, err := a.ReserveSpillDisk(100 * GiB)
must(err)
defer releasedFile.Release()
liveFile, err := live.ReserveSpillDisk(28 * GiB)
must(err)
defer liveFile.Release()
sampledAvailable := 128 * GiB
if !releasedFile.Release() { t.Fatal("release failed") }
// Actual free space is now 228 GiB; no external consumption.
if !stale { sampledAvailable = 228 * GiB }
must(b.setAutomaticSpillDiskCapFromAvailable(sampledAvailable))
capAfterPublish := b.SpillDiskCap()
must(b.setAutomaticSpillDiskCapFromAvailable(228 * GiB))
capAfterFreshSample := b.SpillDiskCap()
growErr := liveFile.Grow(100 * GiB)
t.Logf("cap_after_publish=%dGiB cap_after_fresh=%dGiB grow100=%v",
capAfterPublish/GiB, capAfterFreshSample/GiB, growErr)
if capAfterPublish != 192*GiB || capAfterFreshSample != 192*GiB {
t.Errorf("owned-file release without external growth tightened the 192GiB envelope")
}
if growErr != nil {
t.Errorf("128GiB total spill must fit the unchanged 192GiB envelope: %v", growErr)
}
})
}
}GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test \
-p=2 -v -count=1 -timeout=90s \
-run '^TestSpillSnapshotReleaseInterleaving$' ./pkg/vm/processAdditional information
Source boundaries:
- Sampling occurs before shared-budget publication.
- Old availability is combined with current ownership; live cap cannot recover upward.
- Existing coherent-snapshot test already states the no-double-counting intent.
The automatic sampling/publication path was introduced by #29646 (4e58756c8462ad466051c68867667d51e8b9dcb8); it is absent from the parent. This attribution concerns the reproduced snapshot defect, not all performance changes in that PR.
Relationship to the nightly investigation: this defect was found while investigating BigData main I7, which failed with shared-CN spill used=limit=263869922647. The nightly failure is NOT proven to be caused by the release interleaving above. In particular, the sampled CN release counter was flat during I7 until failure cleanup. The incident still needs its exact automatic-cap update and filesystem-sample history; cache/external storage pressure remains an alternative. This issue reports the independently reproduced MO defect and must not be treated as a complete RCA of that nightly failure.
Validation of a future fix should cover a coherent control, release between sampling/publication, overlapping refreshes, genuine external disk growth, explicit limits, and continued finite admission under concurrent reservations.
Activity
fix(process): discard stale automatic spill disk capacity samples (#3…
XuPeng-SH commentedon Oct 16, 2026
转测 @Ariznawlll。
已在 main 提交
0723ae37b1183a03bac9eda16669dfc7e474dfb8对关联修复 #30356 完成本 issue 对应的定向验证,所测场景通过。过期自动 spill 容量采样、采样期间释放、无可用采样、共享 ledger 场景通过,并通过 race 检查。
测试入口:
TestAutomaticSpillDiskCapTracksIdleStorageWithoutGrowingLiveEnvelopeTestAutomaticSpillDiskCapInvalidatedSamplesTestAutomaticSpillDiskCapReleaseDuringSampleTestAutomaticSpillDiskCapUnavailableSampleTestGetExecutionResourceBudgetSamplesSharedSpillLedger请在目标验收版本复核后决定关闭;本次转测保留 issue 为 OPEN。
Ariznawlll commentedon Oct 19, 2026
测试版本
8ef2eaf4d923bdb4136dd81a50850e8eced0f368;修复 PR #30356 为 MERGED,merge commitc2b990cd7122c30f3adf7f9a5c20d798c18f3989已确认进入该 main。pkg/vm/process的真实资源预算代码上执行;未使用共享 TKE 或大容量真实磁盘。此 issue 报告的是可确定重现的采样/账本交错,未证明它就是历史 BigData I7 事故的根因。原问题验证
独立临时验收探针从
256 GiB可用空间建立192 GiB自动 spill cap,分别为两个 generation 预留100 GiB与28 GiB。在采样返回旧的128 GiB可用空间前释放前者,随后刷新为真实的228 GiB;三轮实际 cap 均保持192 GiB,后者再增长100 GiB均成功,最终账本实际使用128 GiB。修复前报告的错误结果是 cap 被压至117 GiB并拒绝此增长。Happy Path 覆盖
“先释放、再采新值”的相干对照同样得到 cap
192 GiB,28+100=128 GiB预留成功。独立探针-race -count=3,三个场景每轮均通过;临时探针执行后已从隔离工作树删除,没有改动用户主工作树。Unhappy Path 覆盖
另设真实外部空间消耗对照:释放
100 GiB后,外部另消耗100 GiB,有效样本仍为128 GiB;三轮实际 cap 正确收紧到117 GiB,申请使总预留达128 GiB均被拒绝,失败后账本仍为28 GiB。这验证修复没有简单禁用磁盘 admission。合入测试还覆盖 reserve、grow、reconcile、release+reserve、显式 cap 覆盖、较新样本、关闭与不可用样本的过期判定。白盒验证
核对 PR #30356 的实现:在共享预算账本读取 epoch,采样不持有资源锁,发布时若关闭、样本无效或 epoch 已改变则丢弃旧样本;预留/释放/显式 cap 等所有权变化会推进 epoch。原有
TestAutomaticSpillDiskCapReleaseDuringSample、TestAutomaticSpillDiskCapInvalidatedSamples、TestAutomaticSpillDiskCapUnavailableSample、TestGetExecutionResourceBudgetSamplesSharedSpillLedger和外部消耗/显式限额控制,在当前 main 上-race -count=3全部 PASS;完整./pkg/vm/process组件包-race -count=3也 PASS。回归测试
这个缺陷的触发点是进程内采样回调与共享 spill ledger 的所有权交错,无法由确定性 SQL 输出准确触发;因此使用已合入 MatrixOne main 的 Go 组件/race 回归,不添加会产生虚假成功 oracle 的 MOTR SQL 用例。真实 BigData I7 全规模重跑、文件系统物理耗尽及跨节点故障注入未执行,也不以此报告替代该 nightly 的独立根因调查。
测试证据
cap=192 GiB、增长后used=128 GiB;真实外部压力为cap=117 GiB、增长拒绝且used=28 GiB;每种3/3,race 开启。-race -count=3PASS;完整pkg/vm/process包-race -count=3PASS。源码与定向测试位于 PR fix(process): discard stale automatic spill disk capacity samples #30356;本地隔离工作树清理后无临时探针文件。测试结论
测试通过。