mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
Merge pull request #493 from seaweedfs/train/20261123-33
release: OSS train 33 (urgent fallback uploads unpaced #487; ENOSPC retry log rate-limited #488; local headroom check at create and open #490)
This commit is contained in:
commit
2129a73620
16 files changed
+340
-9
No files matched your search
@@ -15,6 +15,6 @@ func registerHostLimitFlags(fs *flag.FlagSet, c *hostlimit.Config) {
|
||||
fs.Int64Var(&c.PayloadBytes, "host-limit-payload-bytes", c.PayloadBytes, "maximum cut payload per slot")
|
||||
fs.Int64Var(&c.COWBytes, "host-limit-cow-bytes", c.COWBytes, "maximum saved COW bytes per slot")
|
||||
fs.Int64Var(&c.BytesPerSecond, "host-limit-upload-bytes-sec", c.BytesPerSecond, "pacing parameter divided per process by cut-slot count; not a host rate cap")
|
||||
fs.IntVar(&c.FallbackVolumes, "host-limit-fallback-volumes", c.FallbackVolumes, "urgent-fallback per-process divisor; coordinated host cap is not enforced")
|
||||
fs.IntVar(&c.FallbackVolumes, "host-limit-fallback-volumes", c.FallbackVolumes, "kept for configuration compatibility; the urgent fallback is not paced (no shared host cap to protect)")
|
||||
fs.DurationVar(&c.MaxHold, "host-limit-max-hold", c.MaxHold, "cut lease timeout; expiration aborts but waits for admitted I/O before release")
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package durable
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
)
|
||||
|
||||
// A pacing refusal before a chunk put names the host limiter, keeps its cause
|
||||
// and sends no put (issue 486: it was reported as the chunk remote).
|
||||
func TestChunkUploadPacingErrorNamesTheLimiter(t *testing.T) {
|
||||
inner := storage.NewMemChunkRemote()
|
||||
bound := &closeBoundRemote{ChunkRemote: inner, done: context.Background(),
|
||||
waitUpload: func(context.Context, int) error { return context.DeadlineExceeded }}
|
||||
err := bound.Put(context.Background(), "chunk-1", []byte("x"))
|
||||
if !errors.Is(err, context.DeadlineExceeded) || !strings.HasPrefix(err.Error(), "hostlimit: upload pacing before put chunk-1: ") {
|
||||
t.Fatalf("pacing error: %v", err)
|
||||
}
|
||||
if _, err := inner.Get(context.Background(), "chunk-1"); err == nil {
|
||||
t.Fatal("a chunk was put although pacing refused it")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package durable
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
)
|
||||
|
||||
// rootFree probes the free bytes of the durable root's file system (nil where
|
||||
// it cannot tell); tests replace it.
|
||||
var rootFree = spillFree
|
||||
|
||||
// Operator guide, Size a host: a full local disk fails guest writes, so a
|
||||
// volume is created only with room for its full size and its WAL, and an
|
||||
// existing volume opens with a loud warning when its remaining sparse growth
|
||||
// and the WAL no longer fit. Neither adds state.
|
||||
func (p *DurableProvider) refuseCreateWithoutHeadroom(volumeID string) error {
|
||||
free := rootFree(p.cfg.StorageRoot)
|
||||
if free == nil {
|
||||
return nil
|
||||
}
|
||||
have, err := free()
|
||||
size := int64(p.cfg.NumBlocks) * int64(p.cfg.BlockSize)
|
||||
if need := size + storage.DefaultWALBytes; err == nil && have < need {
|
||||
return fmt.Errorf("durable: %s has %d bytes free; volume %s needs %d (size %d + WAL %d): free space on it or use a larger file system",
|
||||
p.cfg.StorageRoot, have, volumeID, need, size, storage.DefaultWALBytes)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *DurableProvider) warnLowHeadroom(volumeID, path string, size int64) {
|
||||
free := rootFree(p.cfg.StorageRoot)
|
||||
if free == nil {
|
||||
return
|
||||
}
|
||||
have, err := free()
|
||||
// The store's allocation includes its WAL; only the rest is data.
|
||||
growth := max(size-max(allocatedBytes(path)-storage.DefaultWALBytes, 0), 0)
|
||||
if err == nil && have < growth+storage.DefaultWALBytes {
|
||||
log.Printf("durable: WARNING volume %s: %s has %d bytes free, less than the volume's remaining growth %d + WAL %d; when the disk fills, guest writes fail: free space on it",
|
||||
volumeID, p.cfg.StorageRoot, have, growth, storage.DefaultWALBytes)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package durable
|
||||
|
||||
// SetRootFreeForTest replaces the durable root's free-space probe and returns
|
||||
// the restore function.
|
||||
func SetRootFreeForTest(free int64) func() {
|
||||
old := rootFree
|
||||
rootFree = func(string) func() (int64, error) { return func() (int64, error) { return free, nil } }
|
||||
return func() { rootFree = old }
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package durable_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
)
|
||||
|
||||
// A volume is not created on a durable root without room for its full size
|
||||
// and its WAL (operator guide, Size a host; issue 484), and a refused create
|
||||
// leaves nothing behind: no store, no chunk fresh marker or other sidecar.
|
||||
func TestCreateRefusesWithoutLocalHeadroom(t *testing.T) {
|
||||
defer durable.SetRootFreeForTest(8 << 20)()
|
||||
for _, impl := range []durable.ImplName{durable.ImplWALStore, durable.ImplWALStoreChunk} {
|
||||
t.Run(string(impl), func(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
cfg := durable.ProviderConfig{Impl: impl, StorageRoot: root, BlockSize: 4096, NumBlocks: 65536}
|
||||
if impl == durable.ImplWALStoreChunk {
|
||||
remote := storage.NewMemChunkRemote()
|
||||
cfg.ChunkRemoteFor = func(string) (storage.ChunkRemote, error) { return remote, nil }
|
||||
}
|
||||
p, err := durable.NewDurableProvider(cfg, v1View())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { p.Close() })
|
||||
_, err = p.EnsureStorage("v1")
|
||||
if err == nil || !strings.Contains(err.Error(), "8388608 bytes free") || !strings.Contains(err.Error(), "needs 335544320") {
|
||||
t.Fatalf("create on a root with 8 MiB free: %v", err)
|
||||
}
|
||||
var left []string
|
||||
_ = filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
|
||||
if err == nil && !d.IsDir() {
|
||||
left = append(left, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if len(left) != 0 {
|
||||
t.Fatalf("a refused create left %v", left)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// An existing volume still opens on a root short of headroom, with a loud
|
||||
// warning when its remaining data growth plus the WAL exceed the free space.
|
||||
// A fresh 256 MiB volume holds only its WAL: 256 MiB free is short of the
|
||||
// 256 MiB of data still to grow plus the 64 MiB WAL; 330 MiB free is not.
|
||||
func TestOpenWarnsWithoutLocalHeadroom(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
cfg := durable.ProviderConfig{Impl: durable.ImplWALStore, StorageRoot: root, BlockSize: 4096, NumBlocks: 65536}
|
||||
p, err := durable.NewDurableProvider(cfg, v1View())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := p.EnsureStorage("v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.Close()
|
||||
for _, c := range []struct {
|
||||
free int64
|
||||
warn bool
|
||||
}{{256 << 20, true}, {330 << 20, false}} {
|
||||
var out bytes.Buffer
|
||||
log.SetOutput(&out)
|
||||
restore := durable.SetRootFreeForTest(c.free)
|
||||
p, err := durable.NewDurableProvider(cfg, v1View())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := p.EnsureStorage("v1"); err != nil {
|
||||
t.Fatalf("an existing volume did not open with %d bytes free: %v", c.free, err)
|
||||
}
|
||||
p.Close()
|
||||
restore()
|
||||
log.SetOutput(os.Stderr)
|
||||
if got := strings.Contains(out.String(), "WARNING volume v1"); got != c.warn {
|
||||
t.Fatalf("free %d: warning=%v, want %v:\n%s", c.free, got, c.warn, out.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -845,6 +845,10 @@ func (p *DurableProvider) openOrCreate(volumeID string) (*volHandle, error) {
|
||||
if err := geometry.ValidateBlockGeometry(uint64(p.cfg.NumBlocks), uint64(p.cfg.BlockSize)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Headroom before any sidecar: a refused create leaves nothing behind.
|
||||
if err := p.refuseCreateWithoutHeadroom(volumeID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if p.cfg.Impl == ImplWALStoreChunk {
|
||||
// Durable before the volume file exists: a crash anywhere between
|
||||
// here and the first successful attach leaves a fresh volume.
|
||||
@@ -938,6 +942,7 @@ func (p *DurableProvider) openExisting(volumeID, path string, impl ImplName) (*v
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("durable: OpenWALStore %s: %w", path, err)
|
||||
}
|
||||
p.warnLowHeadroom(volumeID, path, int64(ws.NumBlocks())*int64(ws.BlockSize()))
|
||||
// G6 §1.A α: plumb operator-tunable retention into walstore.
|
||||
// Zero (pre-G6 default) preserves strict checkpoint-driven
|
||||
// recycle.
|
||||
|
||||
@@ -584,7 +584,7 @@ func (r *closeBoundRemote) Put(ctx context.Context, key string, data []byte) err
|
||||
defer end()
|
||||
if r.waitUpload != nil {
|
||||
if err := r.waitUpload(c, len(data)); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("hostlimit: upload pacing before put %s: %w", key, err)
|
||||
}
|
||||
}
|
||||
return r.ChunkRemote.Put(c, key, data)
|
||||
|
||||
@@ -15,3 +15,12 @@ func spillFree(dir string) func() (int64, error) {
|
||||
return int64(st.Bavail) * int64(st.Bsize), nil
|
||||
}
|
||||
}
|
||||
|
||||
// allocatedBytes is the space path's file holds on disk (0 if unknown).
|
||||
func allocatedBytes(path string) int64 {
|
||||
var st syscall.Stat_t
|
||||
if syscall.Stat(path, &st) != nil {
|
||||
return 0
|
||||
}
|
||||
return st.Blocks * 512
|
||||
}
|
||||
@@ -4,3 +4,5 @@ package durable
|
||||
|
||||
// spillFree is nil off Linux: the COW spill cap is the configured one.
|
||||
func spillFree(string) func() (int64, error) { return nil }
|
||||
|
||||
func allocatedBytes(string) int64 { return 0 }
|
||||
@@ -469,10 +469,19 @@ func (l *Limiter) WaitUpload(ctx context.Context, n int) error {
|
||||
l.mu.Unlock()
|
||||
return ErrRevoked
|
||||
}
|
||||
div := l.cfg.NormalSlots + l.cfg.UrgentSlots
|
||||
if l.fallback {
|
||||
div = l.cfg.FallbackVolumes
|
||||
// Only urgent cuts run on the fallback, and with the shared pool
|
||||
// unusable there is no host cap to protect: while every live lease
|
||||
// is a fallback lease, uploads are not paced. A healthy lease beside
|
||||
// one keeps its pacing.
|
||||
onlyFallback := l.fallback && len(l.live) > 0
|
||||
for _, held := range l.live {
|
||||
onlyFallback = onlyFallback && held.fallback
|
||||
}
|
||||
if onlyFallback {
|
||||
l.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
div := l.cfg.NormalSlots + l.cfg.UrgentSlots
|
||||
rate := l.cfg.BytesPerSecond / int64(div)
|
||||
if rate < 1 {
|
||||
rate = 1
|
||||
|
||||
@@ -635,3 +635,54 @@ func TestAdmitClosedDuringPoolAcquisitionIsRevoked(t *testing.T) {
|
||||
t.Fatalf("admission racing Close: id=%d err=%v; want ErrRevoked", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
// An urgent cut on the static fallback (the shared pool is unusable) is not
|
||||
// rate-paced: there is no shared cap to protect, and pacing it at
|
||||
// BytesPerSecond/FallbackVolumes made a seal time out (issue 486).
|
||||
func TestUrgentFallbackUploadIsNotPaced(t *testing.T) {
|
||||
c := testConfig(t)
|
||||
c.Directory += "-missing"
|
||||
l := newTest(t, c)
|
||||
id, err := l.Acquire(context.Background(), Urgent, nil)
|
||||
if err != nil || !l.Snapshot().(Stats).FallbackActive {
|
||||
t.Fatalf("urgent fallback: id=%d err=%v", id, err)
|
||||
}
|
||||
defer l.Release(id)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
for i := 0; i < 4; i++ {
|
||||
if err := l.WaitUpload(ctx, 16<<20); err != nil {
|
||||
t.Fatalf("upload %d on the fallback was paced: %v", i, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// While an urgent cut is on the fallback, a healthy cut admitted after the
|
||||
// pool came back is still paced: only fallback leases alone go unpaced.
|
||||
func TestFallbackDoesNotUnpaceAHealthyLease(t *testing.T) {
|
||||
c := testConfig(t)
|
||||
c.BytesPerSecond = 16 << 20
|
||||
c.Directory += "-missing"
|
||||
l := newTest(t, c)
|
||||
urgent, err := l.Acquire(context.Background(), Urgent, nil)
|
||||
if err != nil || !l.Snapshot().(Stats).FallbackActive {
|
||||
t.Fatalf("urgent fallback: id=%d err=%v", urgent, err)
|
||||
}
|
||||
defer l.Release(urgent)
|
||||
if err := os.Mkdir(c.Directory, 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
normal, err := l.Admit(context.Background(), 1, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("healthy normal admission after the pool came back: %v", err)
|
||||
}
|
||||
defer l.Release(normal)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
if err := l.WaitUpload(ctx, 16<<20); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := l.WaitUpload(ctx, 16<<20); !errors.Is(err, context.DeadlineExceeded) {
|
||||
t.Fatalf("a healthy lease's second 16 MiB upload was not paced beside a fallback lease: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package storage
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -63,13 +64,28 @@ func (r mapCoverageRefusal) Error() string { return ErrMapCoverageStale.Error()
|
||||
func (r mapCoverageRefusal) Unwrap() error { return ErrMapCoverageStale }
|
||||
|
||||
// Owned exclusively by the flusher run loop; no storage lock or I/O ordering
|
||||
// changes. Terminal errors are never rate limited.
|
||||
// changes. Terminal errors are never rate limited; a retried ENOSPC is.
|
||||
type checkpointLogLimiter struct {
|
||||
last time.Time
|
||||
suppressed uint64
|
||||
// A full local disk fails every retry with ENOSPC; one line per 30 s.
|
||||
noSpaceLast time.Time
|
||||
noSpaceSuppressed uint64
|
||||
}
|
||||
|
||||
func (l *checkpointLogLimiter) report(err error, now time.Time) {
|
||||
// A latched store fault is terminal even when ENOSPC is its cause: it is
|
||||
// logged every time. Only a retried ENOSPC (no RecoveryFailure) is limited.
|
||||
var terminal *RecoveryFailure
|
||||
if errors.Is(err, syscall.ENOSPC) && !errors.As(err, &terminal) {
|
||||
if !l.noSpaceLast.IsZero() && now.Sub(l.noSpaceLast) < 30*time.Second {
|
||||
l.noSpaceSuppressed++
|
||||
return
|
||||
}
|
||||
log.Printf("storage: flusher: local disk full, retrying suppressed=%d: %v", l.noSpaceSuppressed, err)
|
||||
l.noSpaceLast, l.noSpaceSuppressed = now, 0
|
||||
return
|
||||
}
|
||||
if !errors.Is(err, ErrMapCoverageStale) {
|
||||
log.Printf("storage: flusher: %v", err)
|
||||
return
|
||||
|
||||
@@ -6,7 +6,9 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -191,3 +193,51 @@ func TestCheckpointDiagnostics_LastAdvanceFollowsOnlyAdvances(t *testing.T) {
|
||||
t.Fatalf("classification: s=%d r=%d f=%d", i.checkpointSuccesses.Load(), i.checkpointRefusals.Load(), i.checkpointFailures.Load())
|
||||
}
|
||||
}
|
||||
|
||||
// The flusher retries an extent write that failed with ENOSPC every cycle; on
|
||||
// a full local disk that is one log line per cycle (issue 484). It is logged
|
||||
// once per 30 s with the count of suppressed repeats.
|
||||
func TestCheckpointDiagnostics_NoSpaceRetryLogRateLimit(t *testing.T) {
|
||||
var out bytes.Buffer
|
||||
old := log.Writer()
|
||||
log.SetOutput(&out)
|
||||
t.Cleanup(func() { log.SetOutput(old) })
|
||||
var limiter checkpointLogLimiter
|
||||
now := time.Unix(100, 0)
|
||||
full := fmt.Errorf("flusher: write extent LBA 653: %w", &os.PathError{Op: "write", Path: "v1.bin", Err: syscall.ENOSPC})
|
||||
for i := 0; i < 100; i++ {
|
||||
limiter.report(full, now.Add(time.Duration(i)*100*time.Millisecond))
|
||||
}
|
||||
limiter.report(full, now.Add(31*time.Second))
|
||||
got := out.String()
|
||||
if n := strings.Count(got, "no space left on device"); n != 2 || !strings.Contains(got, "suppressed=99") {
|
||||
t.Fatalf("want 2 lines, the second with suppressed=99; got %d:\n%s", n, got)
|
||||
}
|
||||
}
|
||||
|
||||
// A terminal fault with ENOSPC as its cause (the latched append or fsync
|
||||
// failure the flusher returns each cycle) stays unlimited: only the retried
|
||||
// ENOSPC is rate-limited.
|
||||
func TestCheckpointDiagnostics_TerminalNoSpaceIsNotRateLimited(t *testing.T) {
|
||||
var out bytes.Buffer
|
||||
old := log.Writer()
|
||||
log.SetOutput(&out)
|
||||
t.Cleanup(func() { log.SetOutput(old) })
|
||||
var limiter checkpointLogLimiter
|
||||
now := time.Unix(100, 0)
|
||||
terminal := NewSubstrateIOFailure(fmt.Errorf("%w: %w", ErrAppendFailed, syscall.ENOSPC), "append failed")
|
||||
limiter.report(terminal, now)
|
||||
limiter.report(terminal, now.Add(time.Second))
|
||||
got := out.String()
|
||||
if n := strings.Count(got, "no space left on device"); n != 2 || strings.Contains(got, "retrying") {
|
||||
t.Fatalf("terminal ENOSPC faults were limited or relabelled (%d lines):\n%s", n, got)
|
||||
}
|
||||
// The window resets: a retried ENOSPC after 30 s is logged again with its count.
|
||||
full := fmt.Errorf("write extent: %w", syscall.ENOSPC)
|
||||
limiter.report(full, now)
|
||||
limiter.report(full, now.Add(29*time.Second))
|
||||
limiter.report(full, now.Add(30*time.Second))
|
||||
if got := out.String(); strings.Count(got, "retrying") != 2 || !strings.Contains(got, "suppressed=1") {
|
||||
t.Fatalf("30 s window:\n%s", got)
|
||||
}
|
||||
}
|
||||
@@ -171,6 +171,9 @@ type WALStore struct {
|
||||
// numBlocks defines the addressable block range; blockSize is the IO
|
||||
// unit (default 4096 if zero). The on-disk file is preallocated to
|
||||
// hold the superblock + WAL region + a fully addressable extent.
|
||||
// DefaultWALBytes is the WAL region a created store reserves.
|
||||
const DefaultWALBytes = 64 << 20
|
||||
|
||||
func CreateWALStore(path string, numBlocks uint32, blockSize int) (*WALStore, error) {
|
||||
return CreateWALStoreWithOptions(path, numBlocks, blockSize, WALStoreOptions{})
|
||||
}
|
||||
@@ -192,7 +195,7 @@ func CreateWALStoreWithOptions(path string, numBlocks uint32, blockSize int, opt
|
||||
if cb == 0 {
|
||||
cb = 1024
|
||||
}
|
||||
return createWALStoreV3Configured(path, numBlocks, uint32(blockSize), 64*1024*1024, opts.WMode, 0, uint64(cb), opts)
|
||||
return createWALStoreV3Configured(path, numBlocks, uint32(blockSize), DefaultWALBytes, opts.WMode, 0, uint64(cb), opts)
|
||||
}
|
||||
|
||||
// OpenWALStore opens an existing store file WITHOUT recovering it.
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -984,3 +985,20 @@ func TestWALStoreV3FlusherCheckpointIsClampedToTheAcknowledgedW(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ENOSPC on the WAL append itself (not behind it, in the flusher) is the
|
||||
// permanent, latched store fault, as the disk-full ruling scopes it (issue
|
||||
// 484): the error keeps ENOSPC and the latch is a SubstrateIO failure.
|
||||
func TestWALStoreV3AppendNoSpaceIsTheLatchedPermanentFault(t *testing.T) {
|
||||
s, _ := newStoreV3(t, WModeLagged)
|
||||
defer s.Close()
|
||||
writeSynced(t, s, 1, 1)
|
||||
s.v3.w.writeAt = func([]byte, int64) (int, error) { return 0, syscall.ENOSPC }
|
||||
if _, err := s.Write(2, blk(2)); !errors.Is(err, syscall.ENOSPC) {
|
||||
t.Fatalf("append: err = %v, want ENOSPC", err)
|
||||
}
|
||||
var failure *RecoveryFailure
|
||||
if f := s.stickyIOFault(); !errors.As(f, &failure) || failure.Kind != StorageRecoveryFailureSubstrateIO {
|
||||
t.Fatalf("ENOSPC on the append latched %v, want a SubstrateIO failure", f)
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ stateDiagram-v2
|
||||
| From | To | Guard | Enforced in | Protects |
|
||||
|---|---|---|---|---|
|
||||
| — | Opened | v3 A/B descriptors and owned-map dependencies valid, exclusive file ownership acquired; legacy formats refused; backend starts not operational | `core/storage/walstore.go` `OpenWALStoreWithOptions`; `core/frontend/durable/provider.go` `openOrCreate` | `INV-WAL-OPGATE-001`, `INV-WAL-V3-ACTIVATION-001`, `INV-WAL-V3-DESCRIPTOR-001`, `INV-WAL-V3-MAP-PUBLISH-001` |
|
||||
| — | (create refused) | a new volume needs the durable root's free space >= its size + WAL, checked before any sidecar or marker; an existing volume opens and warns when its remaining data growth + WAL exceed the free space | `core/frontend/durable/headroom.go`; `core/frontend/durable/provider.go` `openOrCreate` | `INV-LOCAL-HEADROOM-001` |
|
||||
| Opened | Recovering | the volume is open in the provider | `core/frontend/durable/provider.go` `RecoverVolume` | `INV-WAL-OPGATE-001` |
|
||||
| Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end; the frontend targets start, and `FrontendPrimaryReady` is reported, only once the backend admits I/O (a chunk volume: after its storage claim; attach-pending or fenced reports not ready with the reason); a workspace primary claims HEAD, listens and reports ready only while its lease guard permits now (`WorkspaceLeaseGuard.Held`; without a grant: `NotReadyReason=lease_not_held`, exit 75 after the start-time wait) | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `core/host/volume/status_server.go` `statusProjection`; `core/host/volume/workspace_lease.go` `Held` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001`, `INV-WAL-V3-W-RECOVERY-001`, `INV-WAL-V3-FENCE-001`, `INV-WAL-V3-MAP-PUBLISH-001`, `INV-FE-PRIMARY-READY-OPERATIONAL-001`, `INV-WS-SERVE-LEASE-HELD-001` |
|
||||
| Recovering | RecoveryFailed | a WAL integrity failure or an I/O error; the backend stays not operational and the host blocks local readiness with `wal_corrupt` or `io_error` | `cmd/blockvolume/durable_startup.go` `openAndRecoverDurable`; `core/host/volume/recovery_watchdog.go` `LocalRecoveryHealthReason` | `INV-WAL-TYPED-FAILCLOSED-001`, `INV-WAL-OPGATE-001`, `INV-WAL-V3-W-RECOVERY-001` |
|
||||
@@ -493,7 +494,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO
|
||||
|
||||
## Part B. Invariant ledger
|
||||
|
||||
317 rows: 246 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 302 new.
|
||||
318 rows: 247 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 303 new.
|
||||
|
||||
The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger.
|
||||
|
||||
@@ -839,11 +840,12 @@ Notes:
|
||||
| `INV-HOST-CUT-BUDGET-RESERVE-001` | Each admitted slot, urgent included, carries at most PayloadBytes of cut payload and at most COWBytes of COW side bytes; a reservation beyond COWBytes revokes the slot and aborts its cut. | M7 admitted | `core/hostlimit/limiter.go` `Admit`, `ReserveCOW`; `core/storage/chunk_cut_budget.go` | `TestHostCOWCapAbortsCutAndRetainsPermitUntilJoin` (`core/storage/chunk_host_budget_test.go`); `TestSlotsUrgentAndJoinedRelease` (`core/hostlimit/limiter_test.go`) | `HostBudget` PayloadBound/SpillBound | ACTIVE |
|
||||
| `INV-HOST-CUT-BUDGET-SETTLE-001` | A slot's OS lock is released only after its cut's workers settle and Release is called; cancellation, hold expiry and limiter Close abort the cut but keep the slot until then. | M7 draining → joined → released | `core/hostlimit/limiter.go` `Release`, `releaseLoop`, `revoke`, `Close`; `core/storage/chunk_layer.go` `captureLocked` | `TestCOWAbortHoldsSlotUntilWorkerSettlement`, `TestHoldExpiryAndCloseDoNotSteal`, `TestKilledProcessReleasesButLiveHolderDoesNot` (`core/hostlimit/limiter_test.go`); `TestHostCOWCapAbortsCutAndRetainsPermitUntilJoin` (`core/storage/chunk_host_budget_test.go`) | `HostBudget` HeldUntilJoined | ACTIVE |
|
||||
| `INV-HOST-CUT-BUDGET-CONFIG-001` | A busy configuration lock or a mismatched pool configuration refuses every class, urgent included, with no fallback. | M7 free → admitted (refused) | `core/hostlimit/limiter.go` `pool`, `Admit` | `TestConfigurationLockContentionRefusesAllClasses` (`core/hostlimit/limiter_test.go`) | — | ACTIVE |
|
||||
| `INV-HOST-CUT-BUDGET-FALLBACK-001` | Only urgent admissions (urgent move-final cuts and named seals) proceed while the pool is unavailable, on per-process fallback limits that claim no host-wide bound and are reported as fallback while any such lease lives. | M7 free → admitted (pool unavailable) | `core/hostlimit/limiter.go` `Admit`, `releaseLoop`, `WaitUpload` | `TestUnusablePoolClassPolicy`, `TestLastFallbackReleaseClearsActiveStatus`, `TestConfigurationLockFailurePreservesPoolPolicy` (`core/hostlimit/limiter_test.go`); `TestChunkControl_NamedSnapshotUsesUrgentFallback` (`core/host/volume/chunk_control_adapter_test.go`) | `HostBudget` (fallback excluded) | ACTIVE |
|
||||
| `INV-HOST-CUT-BUDGET-FALLBACK-001` | Only urgent admissions (urgent move-final cuts and named seals) proceed while the pool is unavailable, on a per-process fallback that claims no host-wide bound, leaves uploads unpaced while only fallback leases live, and is reported as fallback while any such lease lives. | M7 free → admitted (pool unavailable) | `core/hostlimit/limiter.go` `Admit`, `releaseLoop`, `WaitUpload` | `TestUnusablePoolClassPolicy`, `TestLastFallbackReleaseClearsActiveStatus`, `TestUrgentFallbackUploadIsNotPaced`, `TestFallbackDoesNotUnpaceAHealthyLease`, `TestConfigurationLockFailurePreservesPoolPolicy` (`core/hostlimit/limiter_test.go`); `TestChunkControl_NamedSnapshotUsesUrgentFallback` (`core/host/volume/chunk_control_adapter_test.go`) | `HostBudget` (fallback excluded) | ACTIVE |
|
||||
| `INV-HOST-CUT-BUDGET-PACING-001` | A process's upload pacing debt carries across its own leases, and a new process starts with no debt. | M7 admitted (upload pacing) | `core/hostlimit/limiter.go` `WaitUpload` | `TestPacingDebtSurvivesOwnLeaseTurnover`, `TestPacingFreshProcessesDoNotShareDebt` (`core/hostlimit/limiter_test.go`) | — | ACTIVE |
|
||||
| `INV-HOST-POOL-CONFIG-001` | A pool configuration is invisible until its complete synced temporary file is atomically renamed under the OS configuration lock. A killed initializer cannot leave a partial visible configuration that strands successors. | M7 configuration preparation/publication | `core/hostlimit` `publishConfig` | `TestKilledInitializerDoesNotPublishPartialConfiguration` | `HostBudget` NoPartialConfig/ConfigBeforeAdmission (filesystem atomicity checked natively) | ACTIVE |
|
||||
| `INV-HOST-URGENT-PENDING-001` | While an urgent cut holds its slot, or a caller holds HoldUrgentPending, every Normal admission on the host is refused with ErrUrgentPending (a held-slot wait); urgent admissions still run. | M7 host cut admission (Normal before a slot) | `core/hostlimit/limiter.go` `pool`, `Admit`; `core/hostlimit/pending.go` `HoldUrgentPending` | `TestNormalWaitsWhileUrgentPendingIsHeld`, `TestUrgentLeaseHoldsThePendingSignal` (`core/hostlimit/pending_test.go`); `TestSlotsUrgentAndJoinedRelease` (`core/hostlimit/limiter_test.go`) | — | ACTIVE |
|
||||
| `INV-HOST-LAUNCH-CHECK-001` | blockvolume refuses to start with a --host-limit-dir that is missing or not a directory, under a temporary directory, on a network file system, or already in use with different host-limit flags. | M7 host cut admission (process start) | `core/hostlimit/launch.go` `CheckLaunch`; `core/hostlimit/remotefs_linux.go`; `cmd/blockvolume/main.go` | `TestCheckLaunch` (`core/hostlimit/pending_test.go`) | — | ACTIVE |
|
||||
| `INV-LOCAL-HEADROOM-001` | blockvolume refuses to create a volume when the durable root's file system has less free space than the volume size plus its WAL, naming both numbers, and warns at start when an existing volume's remaining sparse growth plus the WAL exceed the free space; it adds no state. | M1 open/create (durable provider start) | `core/frontend/durable/headroom.go`; `core/frontend/durable/provider.go` `createFresh`, `openExisting` | `TestCreateRefusesWithoutLocalHeadroom`, `TestOpenWarnsWithoutLocalHeadroom` (`core/frontend/durable/headroom_test.go`) | — | ACTIVE |
|
||||
| `INV-HOST-SLOT-BUSY-CODE-001` | The chunk control API refuses a cut, snapshot or detach that host admission refused because every slot is held (or urgent work is pending) with 503 host_slot_busy, retryable; every other capture refusal keeps capture_refused. | M7 free → admitted (refused, wait) | `core/host/volume/chunk_control.go` `chunkErrorCode` | `TestHostSlotHeldHasItsOwnCode` (`core/host/volume/chunk_host_slot_code_test.go`) | — | ACTIVE |
|
||||
| `INV-CUT-INTENT-FIRST-001` | Before the first chunk or segment PUT of a cut or staging round, an intent naming every key of that kind the round preallocated is durable in the filer: one for all candidate chunks, however many upload waves the round uses, and one for all new segments. | M5 Intent → Upload → CAS | `core/storage/chunk_cut_payload.go` `streamCutPayloads`; `core/storage/chunk_layer.go` `captureLocked`, `stage`; `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestChunkIntent_WrittenBeforeFirstUploadAndDeletedAfterCAS`, `TestChunkIntent_FailedPutIntentUploadsNothing` (`core/storage/chunk_layer_intent_test.go`); `TestCutPayloadIntentCountIndependentOfCandidates`, `TestCutPayloadReadsOverlapEarlierUploadsWithinBudget` (`core/storage/chunk_review271_test.go`); `TestChunkPrecopy_StagedUploadsAreCoveredByIntents` (`core/storage/chunk_layer_precopy_test.go`); `TestManifest_ReusesUnchangedRangeAndCrashKeepsOldRoot` (`core/frontend/chunkstore/manifest_test.go`) | `ChunkLifecycleFixed` `GCSafe`; `WorkspaceTakeover` `NoLiveIntentExpired` | ACTIVE |
|
||||
| `INV-CUT-INTENT-CLOSE-001` | Close deletes the intents of reusable uploads and leftover intents, but never an intent of a proposal whose CAS outcome is still unresolved. | M5 Close | `core/storage/chunk_layer.go` `Close`, `captureLocked`, `dropIntents` | `TestChunkCloseDropsReusableButKeepsUnknownCASRoots` (`core/storage/chunk_review271_test.go`); `TestHeadBeltOldCASUnconfirmedKeepsIntentsAndFrontier`, `TestHeadBeltLowerEpochConflictFencesWithoutCleanup`, `TestHeadBeltEmptyBaseForeignPublicationFences` (`core/storage/chunk_head_belt_test.go`) | — | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user