mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
phase134: batch durable backend writes
This commit is contained in:
1 parent
19152945ce
commit
e7affbeed4
22 files changed
+1065
-142
No files matched your search
@@ -36,7 +36,7 @@ This is an **alpha** product path for supported lab clusters, not production.
|
||||
| Actionable read-only CRD status + Events | Available | Bounded SwBlockVolume finalizer lifecycle | Beta candidate |
|
||||
| Returned-replica ACK eligibility executor | Beta candidate | Returned-replica failback runtime | Source-gated |
|
||||
| Returned-replica rebuild traffic | Planned | Frontend publication after failback | Planned |
|
||||
| NVMe/TCP CSI multipath + 100GbE TCP baseline | Source-gated | Backup/snapshot/restore | Planned |
|
||||
| NVMe/TCP CSI multipath + backend write batching | Source-gated | Backup/snapshot/restore | Planned |
|
||||
| Production SLO/performance claims | Not claimed | Hosted production UI | Not claimed |
|
||||
|
||||
## What You Can Do Today
|
||||
@@ -81,7 +81,8 @@ This is an **alpha** product path for supported lab clusters, not production.
|
||||
host-path reconnect gate for scoped `nvme disconnect -d` path loss, plus a
|
||||
live desired path-set replacement gate where CSI-node connects the new
|
||||
desired NVMe path and prunes the stale old host path without remounting the
|
||||
pod. This is a
|
||||
pod, and a durable backend full-block write-batching gate with
|
||||
product-owned `/status/durable` counters. This is a
|
||||
supported-lab source-gated claim, not a broad NVMe
|
||||
compatibility, RoCE/NVMe-RDMA, production HA, or performance/SLO claim.
|
||||
- Replay support bundles offline.
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package durable_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
@@ -366,6 +367,12 @@ func TestDurableProvider_DurableStatuses_ReportWriteProfile(t *testing.T) {
|
||||
if prof.BackendWriteDurationNanos == 0 {
|
||||
t.Fatalf("backend write duration was not recorded: %+v", prof)
|
||||
}
|
||||
if prof.BackendStorageWriteCalls != 1 || prof.BackendStorageWriteBlocks != 1 {
|
||||
t.Fatalf("backend storage write profile mismatch: %+v", prof)
|
||||
}
|
||||
if prof.BackendStorageBatchCalls != 0 || prof.BackendStorageBatchBlocks != 0 {
|
||||
t.Fatalf("single-block write must not report batch profile: %+v", prof)
|
||||
}
|
||||
if prof.BackendSyncOps != 1 || prof.BackendSyncDurationNanos == 0 {
|
||||
t.Fatalf("backend sync profile mismatch: %+v", prof)
|
||||
}
|
||||
@@ -373,6 +380,52 @@ func TestDurableProvider_DurableStatuses_ReportWriteProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDurableProvider_DurableStatuses_ReportWriteBatchProfile(t *testing.T) {
|
||||
for _, impl := range implMatrix() {
|
||||
impl := impl
|
||||
t.Run(string(impl), func(t *testing.T) {
|
||||
p, _, _ := newProvider(t, impl)
|
||||
backend, err := p.Open(context.Background(), "v1")
|
||||
if err != nil {
|
||||
t.Fatalf("Open: %v", err)
|
||||
}
|
||||
if _, err := p.RecoverVolume(context.Background(), "v1"); err != nil {
|
||||
t.Fatalf("RecoverVolume: %v", err)
|
||||
}
|
||||
|
||||
payload := make([]byte, 8192)
|
||||
for i := range payload {
|
||||
payload[i] = byte(i)
|
||||
}
|
||||
if _, err := backend.Write(context.Background(), 0, payload); err != nil {
|
||||
t.Fatalf("Write: %v", err)
|
||||
}
|
||||
got := make([]byte, len(payload))
|
||||
if _, err := backend.Read(context.Background(), 0, got); err != nil {
|
||||
t.Fatalf("Read: %v", err)
|
||||
}
|
||||
if !bytes.Equal(got, payload) {
|
||||
t.Fatalf("readback mismatch at %d", firstDiffIdx(got, payload))
|
||||
}
|
||||
|
||||
statuses := p.DurableStatuses()
|
||||
if len(statuses) != 1 {
|
||||
t.Fatalf("status count=%d want 1: %+v", len(statuses), statuses)
|
||||
}
|
||||
prof := statuses[0].WriteProfile
|
||||
if prof.BackendWriteOps != 1 || prof.BackendWriteBytes != uint64(len(payload)) {
|
||||
t.Fatalf("backend write profile mismatch: %+v", prof)
|
||||
}
|
||||
if prof.BackendStorageWriteCalls != 1 || prof.BackendStorageWriteBlocks != 2 {
|
||||
t.Fatalf("backend storage write profile mismatch: %+v", prof)
|
||||
}
|
||||
if prof.BackendStorageBatchCalls != 1 || prof.BackendStorageBatchBlocks != 2 {
|
||||
t.Fatalf("backend batch profile mismatch: %+v", prof)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDurableProvider_LatchVolumeIdentity_AfterEnsureStorageWithoutFrontendHealthy(t *testing.T) {
|
||||
for _, impl := range implMatrix() {
|
||||
impl := impl
|
||||
|
||||
@@ -125,6 +125,8 @@ var errInvalidOffset = errors.New("durable: invalid (negative) offset")
|
||||
// "I/O before first-open".
|
||||
var errSyncBeforeOpen = errors.New("durable: sync before operational")
|
||||
|
||||
const maxFullBlockBatchBlocks = 64
|
||||
|
||||
// StorageBackend adapts a LogicalStorage into frontend.Backend.
|
||||
type StorageBackend struct {
|
||||
storage storage.LogicalStorage
|
||||
@@ -492,6 +494,26 @@ func (b *StorageBackend) writeBytes(ctx context.Context, offset int64, p []byte)
|
||||
for len(buf) > 0 {
|
||||
lba := uint32(pos / bs)
|
||||
inBlockOff := int(pos % bs)
|
||||
b.mu.Lock()
|
||||
obs := b.observer
|
||||
policy := b.writeAck
|
||||
b.mu.Unlock()
|
||||
if _, ok := b.storage.(storage.WriteBatcher); ok && inBlockOff == 0 && len(buf) >= int(bs) && canBatchFullBlockRun(policy) {
|
||||
fullBlocks := len(buf) / int(bs)
|
||||
if fullBlocks > maxFullBlockBatchBlocks {
|
||||
fullBlocks = maxFullBlockBatchBlocks
|
||||
}
|
||||
if fullBlocks > 1 {
|
||||
written, err := b.writeFullBlockBatch(ctx, lba, buf[:fullBlocks*int(bs)], obs, policy)
|
||||
total += written
|
||||
buf = buf[written:]
|
||||
pos += int64(written)
|
||||
if err != nil {
|
||||
return total, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
available := int(bs) - inBlockOff
|
||||
chunkLen := len(buf)
|
||||
if chunkLen > available {
|
||||
@@ -512,11 +534,6 @@ func (b *StorageBackend) writeBytes(ctx context.Context, offset int64, p []byte)
|
||||
copy(block, existing)
|
||||
copy(block[inBlockOff:], buf[:chunkLen])
|
||||
}
|
||||
|
||||
b.mu.Lock()
|
||||
obs := b.observer
|
||||
policy := b.writeAck
|
||||
b.mu.Unlock()
|
||||
if obs == nil && policy == WriteAckRequireObserverAck {
|
||||
return total, fmt.Errorf("%w: no write observer installed", ErrReplicationAckUnavailable)
|
||||
}
|
||||
@@ -525,27 +542,9 @@ func (b *StorageBackend) writeBytes(ctx context.Context, offset int64, p []byte)
|
||||
if err != nil {
|
||||
return total, fmt.Errorf("durable: write lba=%d: %w", lba, err)
|
||||
}
|
||||
// Replication fan-out (T4a-6 hook). Snapshot the observer under
|
||||
// b.mu so a concurrent SetWriteObserver doesn't see us reading
|
||||
// a stale pointer. Error is logged best-effort — peer layer
|
||||
// degrades; the Write itself has already succeeded locally.
|
||||
// G5-5 instrumentation: log every write hit to the observer
|
||||
// hook so we can disambiguate "WriteObserver never wired" from
|
||||
// "wired but fan-out fails downstream". obs==nil at write time
|
||||
// indicates SetWriteObserver wasn't called BEFORE the iSCSI
|
||||
// initiator started writing — a timing race in main.go.
|
||||
if obs == nil {
|
||||
log.Printf("durable: write observer NIL — replication fan-out skipped (lba=%d lsn=%d) — SetWriteObserver not yet wired",
|
||||
lba, lsn)
|
||||
} else {
|
||||
log.Printf("durable: write observer dispatch lba=%d lsn=%d", lba, lsn)
|
||||
if werr := obs.Observe(ctx, lba, lsn, block); werr != nil {
|
||||
log.Printf("durable: replication fan-out failed lba=%d lsn=%d: %v",
|
||||
lba, lsn, werr)
|
||||
if policy == WriteAckRequireObserverAck {
|
||||
return total + chunkLen, fmt.Errorf("%w: %w", ErrReplicationAckUnavailable, werr)
|
||||
}
|
||||
}
|
||||
b.profile.recordBackendStorageWrite(1, false)
|
||||
if err := b.observeWrite(ctx, lba, lsn, block, obs, policy); err != nil {
|
||||
return total + chunkLen, err
|
||||
}
|
||||
total += chunkLen
|
||||
buf = buf[chunkLen:]
|
||||
@@ -554,6 +553,60 @@ func (b *StorageBackend) writeBytes(ctx context.Context, offset int64, p []byte)
|
||||
return total, nil
|
||||
}
|
||||
|
||||
func canBatchFullBlockRun(policy WriteAckPolicy) bool {
|
||||
return policy != WriteAckRequireObserverAck
|
||||
}
|
||||
|
||||
func (b *StorageBackend) writeFullBlockBatch(ctx context.Context, startLBA uint32, p []byte, obs WriteObserver, policy WriteAckPolicy) (int, error) {
|
||||
batcher, ok := b.storage.(storage.WriteBatcher)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("durable: write batch unsupported")
|
||||
}
|
||||
bs := b.blockSize
|
||||
blockCount := len(p) / bs
|
||||
blocks := make([][]byte, blockCount)
|
||||
for i := range blocks {
|
||||
blocks[i] = p[i*bs : (i+1)*bs]
|
||||
}
|
||||
lsns, err := batcher.WriteBatch(startLBA, blocks)
|
||||
if len(lsns) > 0 {
|
||||
b.profile.recordBackendStorageWrite(len(lsns), true)
|
||||
}
|
||||
for i, lsn := range lsns {
|
||||
block := blocks[i]
|
||||
lba := startLBA + uint32(i)
|
||||
if obsErr := b.observeWrite(ctx, lba, lsn, block, obs, policy); obsErr != nil {
|
||||
return (i + 1) * bs, obsErr
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return len(lsns) * bs, fmt.Errorf("durable: write batch lba=%d blocks=%d: %w", startLBA, blockCount, err)
|
||||
}
|
||||
if len(lsns) != blockCount {
|
||||
return len(lsns) * bs, fmt.Errorf("durable: write batch lba=%d returned %d LSNs for %d blocks", startLBA, len(lsns), blockCount)
|
||||
}
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (b *StorageBackend) observeWrite(ctx context.Context, lba uint32, lsn uint64, block []byte, obs WriteObserver, policy WriteAckPolicy) error {
|
||||
// Replication fan-out (T4a-6 hook). Error is logged best-effort
|
||||
// unless the ack policy requires observer acknowledgement.
|
||||
if obs == nil {
|
||||
log.Printf("durable: write observer NIL — replication fan-out skipped (lba=%d lsn=%d) — SetWriteObserver not yet wired",
|
||||
lba, lsn)
|
||||
return nil
|
||||
}
|
||||
log.Printf("durable: write observer dispatch lba=%d lsn=%d", lba, lsn)
|
||||
if werr := obs.Observe(ctx, lba, lsn, block); werr != nil {
|
||||
log.Printf("durable: replication fan-out failed lba=%d lsn=%d: %v",
|
||||
lba, lsn, werr)
|
||||
if policy == WriteAckRequireObserverAck {
|
||||
return fmt.Errorf("%w: %w", ErrReplicationAckUnavailable, werr)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Compile-time check that StorageBackend satisfies frontend.Backend.
|
||||
// Catches interface drift at build time rather than runtime.
|
||||
var _ frontend.Backend = (*StorageBackend)(nil)
|
||||
@@ -459,6 +459,24 @@ func TestG9A_StorageBackend_WriteAckPolicy_RequireObserverAckFailsWithoutObserve
|
||||
}
|
||||
}
|
||||
|
||||
func TestG9A_StorageBackend_WriteAckPolicy_DisablesBatchWithoutObserver(t *testing.T) {
|
||||
for _, f := range logicalStorageFactories() {
|
||||
f := f
|
||||
t.Run(f.name, func(t *testing.T) {
|
||||
b, _, _ := newTestBackend(t, f, 4, 4096)
|
||||
b.SetWriteAckPolicy(durable.WriteAckRequireObserverAck)
|
||||
|
||||
n, err := b.Write(context.Background(), 0, make([]byte, 8192))
|
||||
if !errors.Is(err, durable.ErrReplicationAckUnavailable) {
|
||||
t.Fatalf("strict batch-shaped Write without observer: want ErrReplicationAckUnavailable, got n=%d err=%v", n, err)
|
||||
}
|
||||
if n != 0 {
|
||||
t.Fatalf("strict write must fail before local batch write, n=%d", n)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestG9A_StorageBackend_WriteAckPolicy_RequireObserverAckPropagatesObserverError(t *testing.T) {
|
||||
observerErr := errors.New("replica recovering")
|
||||
for _, f := range logicalStorageFactories() {
|
||||
|
||||
@@ -15,6 +15,10 @@ type WriteProfileStatus struct {
|
||||
BackendWriteOps uint64
|
||||
BackendWriteBytes uint64
|
||||
BackendWriteDurationNanos uint64
|
||||
BackendStorageWriteCalls uint64
|
||||
BackendStorageWriteBlocks uint64
|
||||
BackendStorageBatchCalls uint64
|
||||
BackendStorageBatchBlocks uint64
|
||||
BackendSyncOps uint64
|
||||
BackendSyncDurationNanos uint64
|
||||
}
|
||||
@@ -26,6 +30,10 @@ type writeProfile struct {
|
||||
backendWriteOps atomic.Uint64
|
||||
backendWriteBytes atomic.Uint64
|
||||
backendWriteDurationNanos atomic.Uint64
|
||||
backendStorageWriteCalls atomic.Uint64
|
||||
backendStorageWriteBlocks atomic.Uint64
|
||||
backendStorageBatchCalls atomic.Uint64
|
||||
backendStorageBatchBlocks atomic.Uint64
|
||||
backendSyncOps atomic.Uint64
|
||||
backendSyncDurationNanos atomic.Uint64
|
||||
}
|
||||
@@ -48,6 +56,18 @@ func (p *writeProfile) recordBackendWrite(bytes int, d time.Duration) {
|
||||
p.backendWriteDurationNanos.Add(durationNanos(d))
|
||||
}
|
||||
|
||||
func (p *writeProfile) recordBackendStorageWrite(blocks int, batched bool) {
|
||||
if blocks <= 0 {
|
||||
return
|
||||
}
|
||||
p.backendStorageWriteCalls.Add(1)
|
||||
p.backendStorageWriteBlocks.Add(uint64(blocks))
|
||||
if batched {
|
||||
p.backendStorageBatchCalls.Add(1)
|
||||
p.backendStorageBatchBlocks.Add(uint64(blocks))
|
||||
}
|
||||
}
|
||||
|
||||
func (p *writeProfile) recordBackendSync(d time.Duration) {
|
||||
p.backendSyncOps.Add(1)
|
||||
p.backendSyncDurationNanos.Add(durationNanos(d))
|
||||
@@ -71,6 +91,10 @@ func (p *writeProfile) snapshot() WriteProfileStatus {
|
||||
BackendWriteOps: p.backendWriteOps.Load(),
|
||||
BackendWriteBytes: p.backendWriteBytes.Load(),
|
||||
BackendWriteDurationNanos: p.backendWriteDurationNanos.Load(),
|
||||
BackendStorageWriteCalls: p.backendStorageWriteCalls.Load(),
|
||||
BackendStorageWriteBlocks: p.backendStorageWriteBlocks.Load(),
|
||||
BackendStorageBatchCalls: p.backendStorageBatchCalls.Load(),
|
||||
BackendStorageBatchBlocks: p.backendStorageBatchBlocks.Load(),
|
||||
BackendSyncOps: p.backendSyncOps.Load(),
|
||||
BackendSyncDurationNanos: p.backendSyncDurationNanos.Load(),
|
||||
}
|
||||
|
||||
@@ -19,26 +19,26 @@ package storage
|
||||
//
|
||||
// What the contract guarantees (single-node):
|
||||
//
|
||||
// 1. Acked data (covered by a Sync that returned nil) survives
|
||||
// both clean restart AND process kill. The kill case is verified
|
||||
// by a simulated-crash test that drops the underlying file
|
||||
// handle without going through Close — no implicit fsync, no
|
||||
// housekeeping. The clean restart case is the standard
|
||||
// Sync -> Close -> Open -> Recover round trip.
|
||||
// 2. Unacked data may disappear after restart but cannot corrupt
|
||||
// acked data: any write whose LSN is > the recovered frontier
|
||||
// is allowed to vanish; any LBA whose write completed before
|
||||
// a successful Sync reads back identical bytes after Recover.
|
||||
// 3. Stable frontier (synced LSN) never goes backward across
|
||||
// Sync calls within one process lifetime AND across
|
||||
// Close+Recover.
|
||||
// 4. Recover is idempotent: calling it twice on the same on-disk
|
||||
// state yields the same recovered LSN and the same readable
|
||||
// contents.
|
||||
// 5. Boundaries() (R, S, H) reports current truth: what's durable,
|
||||
// what WAL still retains, what's the newest write. The engine
|
||||
// uses these to decide recovery class — but the storage must
|
||||
// not interpret them itself.
|
||||
// 1. Acked data (covered by a Sync that returned nil) survives
|
||||
// both clean restart AND process kill. The kill case is verified
|
||||
// by a simulated-crash test that drops the underlying file
|
||||
// handle without going through Close — no implicit fsync, no
|
||||
// housekeeping. The clean restart case is the standard
|
||||
// Sync -> Close -> Open -> Recover round trip.
|
||||
// 2. Unacked data may disappear after restart but cannot corrupt
|
||||
// acked data: any write whose LSN is > the recovered frontier
|
||||
// is allowed to vanish; any LBA whose write completed before
|
||||
// a successful Sync reads back identical bytes after Recover.
|
||||
// 3. Stable frontier (synced LSN) never goes backward across
|
||||
// Sync calls within one process lifetime AND across
|
||||
// Close+Recover.
|
||||
// 4. Recover is idempotent: calling it twice on the same on-disk
|
||||
// state yields the same recovered LSN and the same readable
|
||||
// contents.
|
||||
// 5. Boundaries() (R, S, H) reports current truth: what's durable,
|
||||
// what WAL still retains, what's the newest write. The engine
|
||||
// uses these to decide recovery class — but the storage must
|
||||
// not interpret them itself.
|
||||
//
|
||||
// What the contract does NOT cover:
|
||||
//
|
||||
@@ -210,3 +210,11 @@ type LogicalStorage interface {
|
||||
// Close, only Recover is valid; Read/Write must error.
|
||||
Close() error
|
||||
}
|
||||
|
||||
// WriteBatcher is an optional LogicalStorage extension for contiguous
|
||||
// full-block write batches. Each block still receives its own LSN and recovery
|
||||
// entry; batching is only an execution optimization and must not change
|
||||
// per-LBA recovery semantics.
|
||||
type WriteBatcher interface {
|
||||
WriteBatch(startLBA uint32, blocks [][]byte) ([]uint64, error)
|
||||
}
|
||||
@@ -116,6 +116,38 @@ func (s *Store) Write(lba uint32, data []byte) (uint64, error) {
|
||||
return lsn, nil
|
||||
}
|
||||
|
||||
func (s *Store) WriteBatch(startLBA uint32, blocks [][]byte) ([]uint64, error) {
|
||||
if len(blocks) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
if uint64(startLBA)+uint64(len(blocks)) > uint64(s.numBlocks) {
|
||||
return nil, fmt.Errorf("memorywal: batch [%d,%d) out of range (max %d)", startLBA, uint64(startLBA)+uint64(len(blocks)), s.numBlocks)
|
||||
}
|
||||
for i, data := range blocks {
|
||||
if len(data) != s.blockSize {
|
||||
return nil, fmt.Errorf("memorywal: batch block %d data size %d != block size %d", i, len(data), s.blockSize)
|
||||
}
|
||||
}
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.closed {
|
||||
return nil, errors.New("memorywal: WriteBatch after Close")
|
||||
}
|
||||
lsns := make([]uint64, len(blocks))
|
||||
for i, data := range blocks {
|
||||
cp := make([]byte, s.blockSize)
|
||||
copy(cp, data)
|
||||
lsn := s.nextLSN
|
||||
s.nextLSN++
|
||||
if s.retainStart == 0 {
|
||||
s.retainStart = lsn
|
||||
}
|
||||
lsns[i] = lsn
|
||||
s.records = append(s.records, walRecord{LSN: lsn, LBA: startLBA + uint32(i), Flags: storage.RecoveryEntryWrite, Data: cp})
|
||||
}
|
||||
return lsns, nil
|
||||
}
|
||||
|
||||
func (s *Store) Read(lba uint32) ([]byte, error) {
|
||||
if lba >= s.numBlocks {
|
||||
return nil, fmt.Errorf("memorywal: LBA %d out of range", lba)
|
||||
|
||||
@@ -30,22 +30,22 @@ const defaultWALSlots = 65536
|
||||
// for reads — by construction the extent is current truth.
|
||||
//
|
||||
// Write path:
|
||||
// 1. read existing extent block (kept in memory for rollback)
|
||||
// 2. pwrite new data to extent
|
||||
// 3. compute dataCRC32
|
||||
// 4. append metadata record to ring (slot = LSN % capacity)
|
||||
// 5. on append failure: rollback extent to saved old data
|
||||
// 1. read existing extent block (kept in memory for rollback)
|
||||
// 2. pwrite new data to extent
|
||||
// 3. compute dataCRC32
|
||||
// 4. append metadata record to ring (slot = LSN % capacity)
|
||||
// 5. on append failure: rollback extent to saved old data
|
||||
//
|
||||
// Sync: one fsync of the file. Covers BOTH the extent pwrite and the
|
||||
// ring append since they share a file. After Sync returns, all
|
||||
// preceding writes' data + metadata are durable.
|
||||
//
|
||||
// Recovery:
|
||||
// 1. scan ring, decode valid records, sort by LSN
|
||||
// 2. compute last-writer-wins map (highest-LSN record per LBA)
|
||||
// 3. for each surviving record, verify the extent block's CRC
|
||||
// against the record's dataCRC32; mismatch → skip (torn write)
|
||||
// 4. set nextLSN = highest valid LSN + 1
|
||||
// 1. scan ring, decode valid records, sort by LSN
|
||||
// 2. compute last-writer-wins map (highest-LSN record per LBA)
|
||||
// 3. for each surviving record, verify the extent block's CRC
|
||||
// against the record's dataCRC32; mismatch → skip (torn write)
|
||||
// 4. set nextLSN = highest valid LSN + 1
|
||||
//
|
||||
// Concurrency: a single mutex guards bookkeeping (nextLSN, syncedLSN,
|
||||
// counters); the ring has its own mutex for slot writes. Writes for
|
||||
@@ -226,6 +226,39 @@ func (s *Store) Write(lba uint32, data []byte) (uint64, error) {
|
||||
return lsn, nil
|
||||
}
|
||||
|
||||
func (s *Store) WriteBatch(startLBA uint32, blocks [][]byte) ([]uint64, error) {
|
||||
if len(blocks) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
if uint64(startLBA)+uint64(len(blocks)) > uint64(s.hdr.NumBlocks) {
|
||||
return nil, fmt.Errorf("smartwal: batch [%d,%d) out of range (max %d)", startLBA, uint64(startLBA)+uint64(len(blocks)), s.hdr.NumBlocks)
|
||||
}
|
||||
for i, data := range blocks {
|
||||
if len(data) != int(s.hdr.BlockSize) {
|
||||
return nil, fmt.Errorf("smartwal: batch block %d data size %d != block size %d", i, len(data), s.hdr.BlockSize)
|
||||
}
|
||||
}
|
||||
s.mu.Lock()
|
||||
if s.closed {
|
||||
s.mu.Unlock()
|
||||
return nil, errors.New("smartwal: WriteBatch after Close")
|
||||
}
|
||||
firstLSN := s.nextLSN
|
||||
s.nextLSN += uint64(len(blocks))
|
||||
s.mu.Unlock()
|
||||
|
||||
lsns := make([]uint64, 0, len(blocks))
|
||||
for i, data := range blocks {
|
||||
lsn := firstLSN + uint64(i)
|
||||
if err := s.writeAt(startLBA+uint32(i), lsn, data, flagWrite); err != nil {
|
||||
return lsns, err
|
||||
}
|
||||
s.bumpHead(lsn)
|
||||
lsns = append(lsns, lsn)
|
||||
}
|
||||
return lsns, nil
|
||||
}
|
||||
|
||||
// writeAt is the shared write path used by Write and ApplyEntry.
|
||||
// Saves prior extent bytes, writes new bytes, computes CRC, appends
|
||||
// to ring, and rolls back on append failure.
|
||||
|
||||
@@ -94,16 +94,136 @@ func (w *walWriter) append(entry *walEntry) (walRelOffset uint64, err error) {
|
||||
return writeOffset, nil
|
||||
}
|
||||
|
||||
// appendBatch writes entries under one WAL-writer critical section. Each entry
|
||||
// remains independently encoded/recoverable; the batch only coalesces adjacent
|
||||
// bytes into fewer pwrite calls when the circular WAL layout allows it.
|
||||
func (w *walWriter) appendBatch(entries []*walEntry) ([]uint64, error) {
|
||||
if len(entries) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
bufs := make([][]byte, len(entries))
|
||||
for i, entry := range entries {
|
||||
buf, err := entry.encode()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("walWriter.appendBatch: encode entry %d: %w", i, err)
|
||||
}
|
||||
if uint64(len(buf)) > w.walSize {
|
||||
return nil, fmt.Errorf("%w: entry size %d exceeds WAL size %d", errWALFull, len(buf), w.walSize)
|
||||
}
|
||||
bufs[i] = buf
|
||||
}
|
||||
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
offsets, finalHead, err := w.planAppendBatch(bufs)
|
||||
if err != nil {
|
||||
return offsets, err
|
||||
}
|
||||
|
||||
localHead := w.logicalHead
|
||||
var pending []byte
|
||||
var pendingStart uint64
|
||||
flushPending := func() error {
|
||||
if len(pending) == 0 {
|
||||
return nil
|
||||
}
|
||||
if _, err := w.fd.WriteAt(pending, int64(w.walOffset+pendingStart)); err != nil {
|
||||
return fmt.Errorf("walWriter.appendBatch: pwrite at %d: %w", w.walOffset+pendingStart, err)
|
||||
}
|
||||
pending = nil
|
||||
return nil
|
||||
}
|
||||
appendPending := func(phys uint64, buf []byte) error {
|
||||
if len(buf) == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(pending) == 0 {
|
||||
pendingStart = phys
|
||||
pending = append(pending, buf...)
|
||||
return nil
|
||||
}
|
||||
if pendingStart+uint64(len(pending)) != phys {
|
||||
if err := flushPending(); err != nil {
|
||||
return err
|
||||
}
|
||||
pendingStart = phys
|
||||
}
|
||||
pending = append(pending, buf...)
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, buf := range bufs {
|
||||
entryLen := uint64(len(buf))
|
||||
physHead := w.physicalPos(localHead)
|
||||
remaining := w.walSize - physHead
|
||||
if remaining < entryLen {
|
||||
padding, err := encodeWALPadding(remaining)
|
||||
if err != nil {
|
||||
return offsets, fmt.Errorf("walWriter.appendBatch: padding: %w", err)
|
||||
}
|
||||
if err := appendPending(physHead, padding); err != nil {
|
||||
return offsets, err
|
||||
}
|
||||
localHead += remaining
|
||||
physHead = 0
|
||||
}
|
||||
if err := appendPending(physHead, buf); err != nil {
|
||||
return offsets, err
|
||||
}
|
||||
localHead += entryLen
|
||||
}
|
||||
if err := flushPending(); err != nil {
|
||||
return offsets, err
|
||||
}
|
||||
w.logicalHead = finalHead
|
||||
return offsets, nil
|
||||
}
|
||||
|
||||
func (w *walWriter) planAppendBatch(bufs [][]byte) ([]uint64, uint64, error) {
|
||||
localHead := w.logicalHead
|
||||
offsets := make([]uint64, 0, len(bufs))
|
||||
used := func() uint64 { return localHead - w.logicalTail }
|
||||
for _, buf := range bufs {
|
||||
entryLen := uint64(len(buf))
|
||||
physHead := w.physicalPos(localHead)
|
||||
remaining := w.walSize - physHead
|
||||
if remaining < entryLen {
|
||||
if used()+remaining+entryLen > w.walSize {
|
||||
return offsets, localHead, errWALFull
|
||||
}
|
||||
localHead += remaining
|
||||
physHead = 0
|
||||
}
|
||||
if used()+entryLen > w.walSize {
|
||||
return offsets, localHead, errWALFull
|
||||
}
|
||||
offsets = append(offsets, physHead)
|
||||
localHead += entryLen
|
||||
}
|
||||
return offsets, localHead, nil
|
||||
}
|
||||
|
||||
// writePadding fills [physPos, physPos+size) with a padding entry so
|
||||
// the next write starts at a clean offset. If size is too small for a
|
||||
// real header, just zeros the bytes — the recovery scanner skips
|
||||
// header-too-short tails.
|
||||
func (w *walWriter) writePadding(size, physPos uint64) error {
|
||||
if size < walEntryHeaderSize {
|
||||
buf := make([]byte, size)
|
||||
_, err := w.fd.WriteAt(buf, int64(w.walOffset+physPos))
|
||||
buf, err := encodeWALPadding(size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(buf) == 0 {
|
||||
return nil
|
||||
}
|
||||
_, err = w.fd.WriteAt(buf, int64(w.walOffset+physPos))
|
||||
return err
|
||||
}
|
||||
|
||||
func encodeWALPadding(size uint64) ([]byte, error) {
|
||||
if size < walEntryHeaderSize {
|
||||
return make([]byte, size), nil
|
||||
}
|
||||
buf := make([]byte, size)
|
||||
le := binary.LittleEndian
|
||||
off := 0
|
||||
@@ -124,8 +244,7 @@ func (w *walWriter) writePadding(size, physPos uint64) error {
|
||||
crc := crc32.ChecksumIEEE(buf[:dataEnd])
|
||||
le.PutUint32(buf[dataEnd:], crc)
|
||||
le.PutUint32(buf[dataEnd+4:], uint32(size))
|
||||
_, err := w.fd.WriteAt(buf, int64(w.walOffset+physPos))
|
||||
return err
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
// advanceTail moves the tail forward by (newPhysTail - currentPhysTail
|
||||
|
||||
@@ -419,6 +419,71 @@ func (s *WALStore) Write(lba uint32, data []byte) (uint64, error) {
|
||||
return lsn, nil
|
||||
}
|
||||
|
||||
func (s *WALStore) WriteBatch(startLBA uint32, blocks [][]byte) ([]uint64, error) {
|
||||
if len(blocks) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
maxLBA := uint32(s.sb.VolumeSize / uint64(s.sb.BlockSize))
|
||||
if uint64(startLBA)+uint64(len(blocks)) > uint64(maxLBA) {
|
||||
return nil, fmt.Errorf("storage: batch [%d,%d) out of range (max %d)", startLBA, uint64(startLBA)+uint64(len(blocks)), maxLBA)
|
||||
}
|
||||
for i, data := range blocks {
|
||||
if len(data) != int(s.sb.BlockSize) {
|
||||
return nil, fmt.Errorf("storage: batch block %d data size %d != block size %d", i, len(data), s.sb.BlockSize)
|
||||
}
|
||||
}
|
||||
|
||||
if s.admission != nil {
|
||||
if err := s.admission.Acquire(s.admissionTimeout); err != nil {
|
||||
return nil, fmt.Errorf("storage: WAL admission: %w", err)
|
||||
}
|
||||
defer s.admission.Release()
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
if s.closed {
|
||||
s.mu.Unlock()
|
||||
return nil, errors.New("storage: WriteBatch after Close")
|
||||
}
|
||||
firstLSN := s.nextLSN
|
||||
s.nextLSN += uint64(len(blocks))
|
||||
s.mu.Unlock()
|
||||
|
||||
entries := make([]*walEntry, len(blocks))
|
||||
lsns := make([]uint64, len(blocks))
|
||||
for i, data := range blocks {
|
||||
dataCopy := make([]byte, len(data))
|
||||
copy(dataCopy, data)
|
||||
lsn := firstLSN + uint64(i)
|
||||
lsns[i] = lsn
|
||||
entries[i] = &walEntry{
|
||||
LSN: lsn,
|
||||
Type: walEntryWrite,
|
||||
LBA: uint64(startLBA + uint32(i)),
|
||||
Length: uint32(len(dataCopy)),
|
||||
Data: dataCopy,
|
||||
}
|
||||
}
|
||||
offsets, err := s.wal.appendBatch(entries)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("storage: WAL batch append: %w", err)
|
||||
}
|
||||
for i, walRelOff := range offsets {
|
||||
s.dm.put(uint64(startLBA+uint32(i)), walRelOff, lsns[i], uint32(len(blocks[i])))
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
lastLSN := lsns[len(lsns)-1]
|
||||
if lastLSN > s.walHead {
|
||||
s.walHead = lastLSN
|
||||
}
|
||||
if s.walTail == 0 {
|
||||
s.walTail = firstLSN
|
||||
}
|
||||
s.mu.Unlock()
|
||||
return lsns, nil
|
||||
}
|
||||
|
||||
// Read returns the current bytes at lba. Dirty entries are served
|
||||
// from the WAL; clean LBAs are served from the extent.
|
||||
func (s *WALStore) Read(lba uint32) ([]byte, error) {
|
||||
|
||||
@@ -55,6 +55,65 @@ func TestWALStore_WriteSyncCloseReopenRead(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWALStore_WriteBatchSyncCloseReopenRead(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "store.bin")
|
||||
|
||||
{
|
||||
s, err := CreateWALStore(path, 16, 4096)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
blocks := [][]byte{
|
||||
makeBlock(4096, 0xA1),
|
||||
makeBlock(4096, 0xA2),
|
||||
makeBlock(4096, 0xA3),
|
||||
}
|
||||
lsns, err := s.WriteBatch(2, blocks)
|
||||
if err != nil {
|
||||
t.Fatalf("WriteBatch: %v", err)
|
||||
}
|
||||
if got, want := len(lsns), len(blocks); got != want {
|
||||
t.Fatalf("WriteBatch LSN count=%d want %d", got, want)
|
||||
}
|
||||
for i := 1; i < len(lsns); i++ {
|
||||
if lsns[i] != lsns[i-1]+1 {
|
||||
t.Fatalf("WriteBatch LSNs not consecutive: %v", lsns)
|
||||
}
|
||||
}
|
||||
if _, err := s.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
s, err := OpenWALStore(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer s.Close()
|
||||
if _, err := s.Recover(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for i, want := range [][]byte{
|
||||
makeBlock(4096, 0xA1),
|
||||
makeBlock(4096, 0xA2),
|
||||
makeBlock(4096, 0xA3),
|
||||
} {
|
||||
got, err := s.Read(uint32(i + 2))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.Equal(got, want) {
|
||||
t.Fatalf("LBA %d: batch bytes did not survive close+reopen", i+2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestWALStore_AckedWritesSurviveSimulatedCrash is the real
|
||||
// crash-consistency proof. A clean Close persists superblock state,
|
||||
// which would mask any per-write durability bug. This test bypasses
|
||||
|
||||
@@ -79,4 +79,6 @@ v0.6 beta candidate adds only a bounded ACK eligibility executor target, not
|
||||
returned-replica rebuild/failback execution. The NVMe/TCP supported-lab path is
|
||||
documented separately because it is source-gated until matching
|
||||
`seaweed-block` and `seaweed-block-csi` images pass a pinned-image release
|
||||
smoke.
|
||||
smoke; it now includes source-gated multipath/reconnect correctness and durable
|
||||
backend write-batching evidence, but still no RoCE/NVMe-RDMA or performance
|
||||
SLO claim.
|
||||
@@ -75,6 +75,7 @@ The supported-lab claim is intentionally narrow:
|
||||
| 131 | Live Kubernetes host-path reconnect through CSI-node owner | PASS |
|
||||
| 132 | Live Kubernetes desired path-set change through CSI-node owner | PASS |
|
||||
| 133 | Live Kubernetes stale host-path pruning after desired path replacement | PASS |
|
||||
| 134 | Durable backend full-block write batching with product-owned counters | PASS |
|
||||
|
||||
Key QA sign-offs:
|
||||
|
||||
@@ -92,6 +93,7 @@ Key QA sign-offs:
|
||||
- `internal/docs/qa-assignments/phase131-nvme-k8s-reconnect-live-qa-signoff.md`
|
||||
- `internal/docs/qa-assignments/phase132-nvme-k8s-desired-path-change-qa-signoff.md`
|
||||
- `internal/docs/qa-assignments/phase133-nvme-k8s-stale-path-prune-qa-signoff.md`
|
||||
- `internal/docs/qa-assignments/phase134-durable-backend-write-batching-qa-signoff.md`
|
||||
|
||||
## Performance Baseline
|
||||
|
||||
@@ -206,6 +208,32 @@ batching as the next performance optimization. That optimization is deferred
|
||||
behind the Phase 127/128 NVMe correctness work and still does not create a
|
||||
throughput/SLO, RoCE, or NVMe/RDMA claim.
|
||||
|
||||
Phase 134 returns to that backend-write bottleneck and adds bounded full-block
|
||||
write batching plus product-owned internal storage-call counters. The old
|
||||
`backend_write_ops` counter remains useful, but it measures frontend
|
||||
`StorageBackend.Write` calls, not internal per-block storage fan-out. The new
|
||||
`backend_storage_*` counters are the evidence for batching:
|
||||
|
||||
```text
|
||||
phase134_durable_backend_write_batching_status=ok
|
||||
target_write_observed=true
|
||||
target_write_bytes=118259712
|
||||
backend_write_bytes=118259712
|
||||
backend_write_ops=3634
|
||||
backend_storage_write_calls=3634
|
||||
backend_storage_write_blocks=28872
|
||||
backend_storage_batch_calls=3613
|
||||
backend_storage_batch_blocks=28851
|
||||
backend_storage_batching_effective=true
|
||||
strict_ack_batch_disabled=true
|
||||
cleanup_status=ok
|
||||
```
|
||||
|
||||
This proves the supported-lab NVMe/TCP write path exercises durable backend
|
||||
batching and still cleans up. It is not a performance/SLO claim; the next
|
||||
performance step is to compare wall-clock write behavior after batching and
|
||||
identify the next dominant cost.
|
||||
|
||||
Phase 127 closes the source/component side of the ANA Change Notice gap:
|
||||
|
||||
```text
|
||||
|
||||
@@ -739,6 +739,17 @@ Recommended order from here:
|
||||
connects the new desired path and prunes the stale old host path for the
|
||||
same NQN using scoped controller disconnects, with pod UID/I/O preserved
|
||||
and cleanup clean.
|
||||
92. Phase 134: Durable Backend Write Batching. **Closed 2026-07-04,
|
||||
runner PASS**
|
||||
Returned to the Phase 126 backend-write bottleneck with a correctness-first
|
||||
batch seam. Contiguous full-block writes now use bounded storage
|
||||
`WriteBatch` calls, `walstore` performs a real batch WAL append path while
|
||||
keeping one WAL record/LSN per block, and `/status/durable` exposes
|
||||
internal storage-call/batch counters. The live NVMe/TCP gate observed
|
||||
`backend_storage_write_blocks=28872`,
|
||||
`backend_storage_write_calls=3634`,
|
||||
`backend_storage_batch_calls=3613`, and clean cleanup. This is not a
|
||||
performance/SLO or NVMe/RDMA claim.
|
||||
|
||||
The internal release-train contract is
|
||||
`internal/docs/ref/operation-layer-v0.5-release-train.md`. Phases 41-44 close
|
||||
|
||||
@@ -1,109 +1,91 @@
|
||||
# Current Plan: Phase 134 Durable Backend Large-Write Batching Gate
|
||||
# Current Plan: Phase 135 Post-Batch NVMe/TCP Write-Path Retriage
|
||||
|
||||
Status: planning.
|
||||
|
||||
Phase 133 closed the Kubernetes NVMe/TCP mounted correctness gap from Phase
|
||||
132:
|
||||
Phase 134 closed the first backend execution fix after the Phase 126 write-path
|
||||
finding:
|
||||
|
||||
```text
|
||||
desired path set changes old->new
|
||||
-> CSI-node owner connects the new desired path
|
||||
-> CSI-node owner prunes the stale old host path for the same NQN
|
||||
-> mounted pod UID/I/O are preserved
|
||||
-> CRD/report/dashboard agree
|
||||
large mounted NVMe/TCP write
|
||||
-> StorageBackend sees frontend writes
|
||||
-> contiguous full-block runs use bounded storage WriteBatch
|
||||
-> walstore batches admission/LSN allocation/WAL append
|
||||
-> /status/durable exposes backend_storage_* counters
|
||||
-> live gate proves backend_storage_write_calls < backend_storage_write_blocks
|
||||
```
|
||||
|
||||
That makes the supported-lab NVMe/TCP mounted path coherent enough to return to
|
||||
the Phase 126 performance finding. Phase 126 showed that the write gap is not
|
||||
network-bound and not dominated by sync time:
|
||||
|
||||
```text
|
||||
network_baseline_mibps=4180.60
|
||||
block_nvme_seq_write_mibps=177.72
|
||||
local_path_seq_write_mibps=1115.47
|
||||
block_vs_local_write_ratio=0.159
|
||||
backend_write_ops=17972
|
||||
backend_write_duration_ms=33186
|
||||
backend_sync_ops=9
|
||||
backend_sync_duration_ms=73
|
||||
top_bottleneck=backend_write
|
||||
next_recommendation=phase127_durable_backend_write_batching
|
||||
```
|
||||
|
||||
The next product change should therefore target backend write fan-out, not
|
||||
RoCE/NVMe-RDMA.
|
||||
The next step is not another protocol feature. It is to rerun the same
|
||||
supported-lab write-path profile with the new counters and decide what actually
|
||||
dominates after batching.
|
||||
|
||||
## Goal
|
||||
|
||||
```text
|
||||
large sequential mounted NVMe/TCP write
|
||||
-> target still receives the same bytes
|
||||
-> durable backend writes fewer/larger physical write operations
|
||||
-> read-back data remains byte-correct
|
||||
-> backend write counters prove the optimization path was exercised
|
||||
-> cleanup remains clean
|
||||
mounted NVMe/TCP write profile after Phase 134 batching
|
||||
-> target/backend/storage counters agree
|
||||
-> wall-clock write/read numbers are captured
|
||||
-> local-path comparator is captured in the same run
|
||||
-> batch counters prove the optimized path is active
|
||||
-> next bottleneck is classified from evidence
|
||||
-> no unsupported performance or RDMA claim is made
|
||||
```
|
||||
|
||||
This phase is an optimization gate, but it must still be correctness-first:
|
||||
partial-block writes, repeated writes to the same LBA, and sync/flush semantics
|
||||
must remain safe.
|
||||
|
||||
## Required Evidence
|
||||
|
||||
```text
|
||||
phase134_durable_backend_write_batching_status=ok
|
||||
phase135_nvme_tcp_post_batch_retriage_status=ok
|
||||
frontend_transport=tcp
|
||||
roce_claim_allowed=false
|
||||
nvme_rdma_claim_allowed=false
|
||||
performance_slo_claim_allowed=false
|
||||
network_baseline_mibps=<observed or unavailable-with-reason>
|
||||
block_nvme_seq_write_mibps=<observed>
|
||||
block_nvme_seq_read_mibps=<observed>
|
||||
local_path_seq_write_mibps=<observed>
|
||||
local_path_seq_read_mibps=<observed>
|
||||
block_vs_local_write_ratio=<observed>
|
||||
target_write_observed=true
|
||||
target_write_bytes=<bytes>
|
||||
backend_write_bytes=<same bytes or justified physical bytes>
|
||||
backend_write_ops_before=<from baseline or control run>
|
||||
backend_write_ops_after=<optimized run>
|
||||
backend_write_op_reduction_ratio=<after/before>
|
||||
backend_write_duration_ms=<observed>
|
||||
backend_write_bytes=<bytes>
|
||||
backend_storage_write_calls=<calls>
|
||||
backend_storage_write_blocks=<blocks>
|
||||
backend_storage_batch_calls=<calls>
|
||||
backend_storage_batch_blocks=<blocks>
|
||||
backend_storage_batching_effective=true
|
||||
backend_sync_ops=<observed>
|
||||
read_after_write_verified=true
|
||||
partial_block_regression_passed=true
|
||||
same_lba_overwrite_regression_passed=true
|
||||
backend_sync_duration_ms=<observed>
|
||||
post_batch_bottleneck=<backend_write|backend_sync|target_protocol|benchmark_shape|unknown>
|
||||
next_recommendation=<specific next phase>
|
||||
cleanup_status=ok
|
||||
```
|
||||
|
||||
The exact throughput number is evidence, not a product claim. PASS requires the
|
||||
operation count and correctness assertions, not a fixed MiB/s target.
|
||||
|
||||
## Boundaries
|
||||
|
||||
- Do not claim NVMe/RDMA, RoCE, GPU Direct, cuFile/cuObject, NIXL, production
|
||||
HA, broad host compatibility, or performance/SLO.
|
||||
- Do not optimize by dropping durability, skipping sync semantics, or assuming
|
||||
sequential-only writes globally.
|
||||
- Do not add broad configurability unless the benchmark proves the default
|
||||
needs a guard.
|
||||
- Do not change frontend publication, failover, reconnect, or Kubernetes
|
||||
lifecycle behavior in this phase.
|
||||
- Do not claim a fixed MiB/s SLO.
|
||||
- Do not claim RoCE, NVMe/RDMA, GPU Direct, cuFile/cuObject, or NIXL.
|
||||
- Do not start NVMe/RDMA until the TCP path's post-batch bottleneck is named.
|
||||
- Do not add another optimization before the profile identifies the next
|
||||
dominant cost.
|
||||
|
||||
## Candidate Implementation
|
||||
## Candidate Work
|
||||
|
||||
1. Inspect the durable backend write path and identify where large sequential
|
||||
target writes are split into many small backend writes.
|
||||
2. Add a minimal batching/coalescing path for contiguous full-block writes.
|
||||
3. Preserve the existing direct path for partial-block or non-contiguous writes
|
||||
unless a safe merge is obvious.
|
||||
4. Add unit tests for:
|
||||
- contiguous full-block batching;
|
||||
- partial-block writes preserving untouched bytes;
|
||||
- same-LBA overwrite ordering;
|
||||
- sync/flush counter behavior.
|
||||
5. Extend the Phase 126 gate or add a Phase134 wrapper that runs the same
|
||||
mounted NVMe/TCP profile shape and captures before/after backend counters.
|
||||
6. Update docs only after the gate proves correctness and product-owned
|
||||
counters show the optimized path.
|
||||
1. Extend the Phase 134 wrapper or add a Phase 135 wrapper that runs the
|
||||
Phase 125/126 profile shape with the new `backend_storage_*` counters.
|
||||
2. Prefer the previous 512MiB profile size for comparability unless the lab is
|
||||
constrained; if a smaller size is used, mark it as non-comparable.
|
||||
3. Keep the same 100GbE frontend IP map (`m01=10.0.0.1,m02=10.0.0.3`) and
|
||||
expected route device (`enp1s0np0`).
|
||||
4. Classify the next bottleneck from evidence:
|
||||
- backend write still dominates -> inspect WAL append / memcpy / checksum;
|
||||
- backend sync dominates -> group commit / flush cadence;
|
||||
- target protocol dominates -> NVMe target copy/queue path;
|
||||
- local-path is also slow -> benchmark/lab shape.
|
||||
5. Update the roadmap/release docs with the classification only after the gate
|
||||
passes.
|
||||
|
||||
## Exit Criteria
|
||||
|
||||
Phase 134 can close only if local correctness tests and a live supported-lab
|
||||
gate both pass. If the optimization does not reduce backend write fan-out, keep
|
||||
the instrumentation and document the next bottleneck instead of claiming a
|
||||
performance improvement.
|
||||
Phase 135 can close when the live supported-lab gate produces a clean profile
|
||||
with active batch counters and a concrete next recommendation. If evidence is
|
||||
ambiguous, close as instrumentation-only and name the missing counter instead
|
||||
of guessing.
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
# Phase 134 Finished Plan: Durable Backend Write Batching
|
||||
|
||||
Status: **closed 2026-07-04, live gate PASS**.
|
||||
|
||||
## Problem
|
||||
|
||||
Phase 126 localized the mounted NVMe/TCP write gap to backend write cost, not to
|
||||
network bandwidth or sync/flush time. During Phase 134 implementation we also
|
||||
found that the existing `backend_write_ops` counter only measured
|
||||
`StorageBackend.Write` calls from the frontend. It did not prove how many
|
||||
internal storage block writes happened underneath one large frontend write.
|
||||
|
||||
## Change
|
||||
|
||||
- Added optional `storage.WriteBatcher` for contiguous full-block write batches.
|
||||
- Routed `StorageBackend.writeBytes` through that seam for aligned full-block
|
||||
runs, capped at 64 blocks per batch.
|
||||
- Kept partial-block and non-contiguous writes on the existing path.
|
||||
- Disabled batching when `WriteAckRequireObserverAck` is active so strict ACK
|
||||
semantics cannot be bypassed.
|
||||
- Implemented batch support in `memorywal`, `walstore`, and `smartwal`.
|
||||
- Made `walstore` perform a real batch append path: one validation/admission
|
||||
pass, one LSN allocation, and coalesced adjacent WAL bytes where possible.
|
||||
Each block still remains an independent WAL record with its own LSN.
|
||||
- Added `/status/durable` write-profile counters:
|
||||
`backend_storage_write_calls`, `backend_storage_write_blocks`,
|
||||
`backend_storage_batch_calls`, and `backend_storage_batch_blocks`.
|
||||
- Extended Phase 120/126 profiling scripts and added the Phase 134 live gate.
|
||||
|
||||
## Evidence
|
||||
|
||||
Local:
|
||||
|
||||
```text
|
||||
go test ./core/frontend/durable ./core/storage/... -count=1
|
||||
go test ./core/frontend/nvme ./core/host/volume ./cmd/blockvolume ./cmd/sw-block -count=1
|
||||
```
|
||||
|
||||
Live:
|
||||
|
||||
```text
|
||||
C:\work\swblock.exe run testops/scenarios/nvme-tcp-durable-backend-write-batching-chain.yaml
|
||||
run bundle: results\20260704-152759-5441
|
||||
20 actions: 20 passed, 0 failed
|
||||
```
|
||||
|
||||
Gate summary:
|
||||
|
||||
```text
|
||||
phase134_durable_backend_write_batching_status=ok
|
||||
target_write_observed=true
|
||||
target_write_bytes=118259712
|
||||
backend_write_bytes=118259712
|
||||
backend_write_ops=3634
|
||||
backend_storage_write_calls=3634
|
||||
backend_storage_write_blocks=28872
|
||||
backend_storage_batch_calls=3613
|
||||
backend_storage_batch_blocks=28851
|
||||
backend_storage_batching_effective=true
|
||||
strict_ack_batch_disabled=true
|
||||
cleanup_status=ok
|
||||
```
|
||||
|
||||
## Boundaries
|
||||
|
||||
Phase 134 is a backend execution improvement and instrumentation close gate. It
|
||||
does not claim a performance SLO, RoCE, NVMe/RDMA, GPU Direct, cuFile/cuObject,
|
||||
NIXL, or production HA. The next performance phase should use the new counters
|
||||
to determine whether backend batching improved wall-clock throughput and what
|
||||
the next bottleneck is.
|
||||
@@ -399,8 +399,18 @@ rebuild, delete safety, or cleanup must start as a separate gated phase.
|
||||
path replacement. CSI-node now connects the new desired path and disconnects
|
||||
only stale host paths for the same NQN that are no longer desired, using
|
||||
scoped controller disconnects. Mounted pod UID/I/O are preserved and
|
||||
CRD/report/dashboard agree. The next NVMe work should return to the Phase 126
|
||||
backend-write bottleneck and durable write batching.
|
||||
CRD/report/dashboard agree.
|
||||
- Phase 134 is closed for durable backend write batching. The previous
|
||||
`backend_write_ops` counter was not enough because it measured
|
||||
`StorageBackend.Write` calls, not internal storage fan-out. The product now
|
||||
has bounded full-block `WriteBatch` execution, real `walstore` batch WAL
|
||||
append, strict-ACK batch disablement, and `/status/durable`
|
||||
`backend_storage_*` counters. The live NVMe/TCP gate observed
|
||||
`backend_storage_write_blocks=28872`,
|
||||
`backend_storage_write_calls=3634`, and
|
||||
`backend_storage_batch_calls=3613` with cleanup clean. The next NVMe work can
|
||||
measure wall-clock improvement and identify the next bottleneck; it should
|
||||
still avoid SLO, RoCE, or NVMe/RDMA claims.
|
||||
- Later protocol candidates: complete a real NVMe/RDMA target, characterize
|
||||
NVMe/TCP performance, or bridge to object/NIXL acceleration where the product
|
||||
surface is object/storage rather than block PVC. Keep these separate so
|
||||
@@ -1010,6 +1020,8 @@ Approximate engineering effort if scope remains tight:
|
||||
gate.
|
||||
- Phase 133 is closed for Kubernetes NVMe stale host-path pruning after desired
|
||||
path replacement.
|
||||
- Phase 134 is closed for durable backend write batching and product-owned
|
||||
`backend_storage_*` counters.
|
||||
- Phase 41-44 are the Operation Layer v0.5 release train: lifecycle-owner
|
||||
foundation, real API/admission proof, first bounded finalizer mutation, and
|
||||
delete lifecycle close gate.
|
||||
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
# Phase 134 Durable Backend Write Batching QA Sign-Off
|
||||
|
||||
Verdict: **PASS**.
|
||||
|
||||
Validated source tree: local `phase134-durable-write-batching` working tree
|
||||
synced to `m02:/tmp/seaweed_block`.
|
||||
|
||||
Run:
|
||||
|
||||
```powershell
|
||||
C:\work\swblock.exe run testops/scenarios/nvme-tcp-durable-backend-write-batching-chain.yaml `
|
||||
-output results\phase134-durable-write-batching-run1.json `
|
||||
-html results\phase134-durable-write-batching-run1.html
|
||||
```
|
||||
|
||||
Run bundle:
|
||||
|
||||
```text
|
||||
results\20260704-152759-5441
|
||||
20 actions: 20 passed, 0 failed
|
||||
```
|
||||
|
||||
## Evidence
|
||||
|
||||
```text
|
||||
phase134_durable_backend_write_batching_status=ok
|
||||
frontend_transport=tcp
|
||||
roce_claim_allowed=false
|
||||
nvme_rdma_claim_allowed=false
|
||||
performance_slo_claim_allowed=false
|
||||
batch_scope=contiguous_full_block_writes
|
||||
batch_max_blocks=64
|
||||
unit_batch_regression_passed=true
|
||||
strict_ack_batch_disabled=true
|
||||
read_after_write_regression_passed=true
|
||||
target_write_observed=true
|
||||
target_write_bytes=118259712
|
||||
backend_write_bytes=118259712
|
||||
backend_write_ops=3634
|
||||
backend_write_duration_ms=11192
|
||||
backend_storage_write_calls=3634
|
||||
backend_storage_write_blocks=28872
|
||||
backend_storage_batch_calls=3613
|
||||
backend_storage_batch_blocks=28851
|
||||
backend_storage_batching_effective=true
|
||||
backend_sync_ops=9
|
||||
cleanup_status=ok
|
||||
```
|
||||
|
||||
## What This Proves
|
||||
|
||||
- The live mounted NVMe/TCP path still writes through the durable backend and
|
||||
exposes target/backend counters through `/status/durable`.
|
||||
- Contiguous full-block writes exercise the new bounded batch path:
|
||||
`backend_storage_batch_calls=3613` and
|
||||
`backend_storage_batch_blocks=28851`.
|
||||
- Internal storage write-call count is lower than block fan-out:
|
||||
`3634 < 28872`.
|
||||
- The strict ACK safety guard is covered by unit tests:
|
||||
batch-shaped writes with `WriteAckRequireObserverAck` and no observer fail
|
||||
before a local batch write.
|
||||
- Cleanup is clean.
|
||||
|
||||
## Boundaries
|
||||
|
||||
This is not a performance SLO, RoCE, NVMe/RDMA, GPU Direct, cuFile/cuObject, or
|
||||
NIXL claim. The wall-clock write number is evidence only. Phase 134 proves the
|
||||
batch seam and counters, not production-grade throughput.
|
||||
|
||||
The existing `backend_write_ops` counter remains a frontend/backend API call
|
||||
counter. Phase 134 adds separate `backend_storage_*` counters because
|
||||
`backend_write_ops` alone cannot prove internal storage fan-out reduction.
|
||||
|
||||
## Additional Local Checks
|
||||
|
||||
```text
|
||||
go test ./core/frontend/durable ./core/storage/... -count=1
|
||||
go test ./core/frontend/nvme ./core/host/volume ./cmd/blockvolume ./cmd/sw-block -count=1
|
||||
```
|
||||
|
||||
Both passed.
|
||||
|
||||
One unrelated local process-harness test still failed during the wider check:
|
||||
|
||||
```text
|
||||
go test ./core/frontend/iscsi -run TestT2Process_ISCSI_ReopenAfterMove_ServesNewLineage -count=1 -v
|
||||
projection did not return to Healthy ... within 30s
|
||||
```
|
||||
|
||||
That test uses a 512-byte partial iSCSI write and does not exercise the new
|
||||
full-block batch path. It should be tracked separately as an iSCSI/process
|
||||
harness flake or bug, not as a Phase 134 blocker.
|
||||
@@ -192,6 +192,10 @@ target_ns = int(field(profile, "TargetWriteDurationNanos", "targetWriteDurationN
|
||||
backend_ops = int(field(profile, "BackendWriteOps", "backendWriteOps", default=0) or 0)
|
||||
backend_bytes = int(field(profile, "BackendWriteBytes", "backendWriteBytes", default=0) or 0)
|
||||
backend_ns = int(field(profile, "BackendWriteDurationNanos", "backendWriteDurationNanos", default=0) or 0)
|
||||
backend_storage_write_calls = int(field(profile, "BackendStorageWriteCalls", "backendStorageWriteCalls", default=0) or 0)
|
||||
backend_storage_write_blocks = int(field(profile, "BackendStorageWriteBlocks", "backendStorageWriteBlocks", default=0) or 0)
|
||||
backend_storage_batch_calls = int(field(profile, "BackendStorageBatchCalls", "backendStorageBatchCalls", default=0) or 0)
|
||||
backend_storage_batch_blocks = int(field(profile, "BackendStorageBatchBlocks", "backendStorageBatchBlocks", default=0) or 0)
|
||||
sync_ops = int(field(profile, "BackendSyncOps", "backendSyncOps", default=0) or 0)
|
||||
sync_ns = int(field(profile, "BackendSyncDurationNanos", "backendSyncDurationNanos", default=0) or 0)
|
||||
def ms(ns):
|
||||
@@ -207,6 +211,10 @@ with open(summary_out, "w") as f:
|
||||
f.write(f"backend_write_ops={backend_ops}\n")
|
||||
f.write(f"backend_write_bytes={backend_bytes}\n")
|
||||
f.write(f"backend_write_duration_ms={ms(backend_ns)}\n")
|
||||
f.write(f"backend_storage_write_calls={backend_storage_write_calls}\n")
|
||||
f.write(f"backend_storage_write_blocks={backend_storage_write_blocks}\n")
|
||||
f.write(f"backend_storage_batch_calls={backend_storage_batch_calls}\n")
|
||||
f.write(f"backend_storage_batch_blocks={backend_storage_batch_blocks}\n")
|
||||
f.write(f"backend_sync_ops={sync_ops}\n")
|
||||
f.write(f"backend_sync_duration_ms={ms(sync_ns)}\n")
|
||||
PY
|
||||
|
||||
+10
@@ -127,6 +127,10 @@ TARGET_MS="$(require_summary_value "${BLOCK_SUMMARY}" target_write_duration_ms)"
|
||||
BACKEND_OPS="$(require_summary_value "${BLOCK_SUMMARY}" backend_write_ops)"
|
||||
BACKEND_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" backend_write_bytes)"
|
||||
BACKEND_MS="$(require_summary_value "${BLOCK_SUMMARY}" backend_write_duration_ms)"
|
||||
BACKEND_STORAGE_WRITE_CALLS="$(require_summary_value "${BLOCK_SUMMARY}" backend_storage_write_calls)"
|
||||
BACKEND_STORAGE_WRITE_BLOCKS="$(require_summary_value "${BLOCK_SUMMARY}" backend_storage_write_blocks)"
|
||||
BACKEND_STORAGE_BATCH_CALLS="$(require_summary_value "${BLOCK_SUMMARY}" backend_storage_batch_calls)"
|
||||
BACKEND_STORAGE_BATCH_BLOCKS="$(require_summary_value "${BLOCK_SUMMARY}" backend_storage_batch_blocks)"
|
||||
SYNC_OPS="$(require_summary_value "${BLOCK_SUMMARY}" backend_sync_ops)"
|
||||
SYNC_MS="$(require_summary_value "${BLOCK_SUMMARY}" backend_sync_duration_ms)"
|
||||
|
||||
@@ -138,6 +142,8 @@ assert_int_ge "${TARGET_OPS}" 1 "target_write_ops"
|
||||
assert_int_ge "${BACKEND_OPS}" 1 "backend_write_ops"
|
||||
assert_int_ge "${TARGET_BYTES}" "${SEQ_BYTES}" "target_write_bytes"
|
||||
assert_int_ge "${BACKEND_BYTES}" "${SEQ_BYTES}" "backend_write_bytes"
|
||||
assert_int_ge "${BACKEND_STORAGE_WRITE_CALLS}" 1 "backend_storage_write_calls"
|
||||
assert_int_ge "${BACKEND_STORAGE_WRITE_BLOCKS}" 1 "backend_storage_write_blocks"
|
||||
|
||||
WRITE_OBSERVATION="$(classify_write_path "${TARGET_MS}" "${BACKEND_MS}" "${SYNC_MS}" "${SYNC_OPS}")"
|
||||
NEXT_RECOMMENDATION="$(recommendation_for "${WRITE_OBSERVATION}")"
|
||||
@@ -156,6 +162,10 @@ write_summary "target_write_duration_ms=${TARGET_MS}"
|
||||
write_summary "backend_write_bytes=${BACKEND_BYTES}"
|
||||
write_summary "backend_write_ops=${BACKEND_OPS}"
|
||||
write_summary "backend_write_duration_ms=${BACKEND_MS}"
|
||||
write_summary "backend_storage_write_calls=${BACKEND_STORAGE_WRITE_CALLS}"
|
||||
write_summary "backend_storage_write_blocks=${BACKEND_STORAGE_WRITE_BLOCKS}"
|
||||
write_summary "backend_storage_batch_calls=${BACKEND_STORAGE_BATCH_CALLS}"
|
||||
write_summary "backend_storage_batch_blocks=${BACKEND_STORAGE_BATCH_BLOCKS}"
|
||||
write_summary "backend_sync_ops=${SYNC_OPS}"
|
||||
write_summary "backend_sync_duration_ms=${SYNC_MS}"
|
||||
write_summary "write_path_observation=${WRITE_OBSERVATION}"
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:-$(pwd)}"
|
||||
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${ROOT}/results/phase134-durable-backend-write-batching-gate}"
|
||||
SUMMARY="${ARTIFACT_DIR}/phase134-durable-backend-write-batching-summary.txt"
|
||||
PHASE126_DIR="${ARTIFACT_DIR}/phase126-profile"
|
||||
SEQ_MIB="${SW_BLOCK_PHASE134_SEQ_MIB:-64}"
|
||||
|
||||
mkdir -p "${ARTIFACT_DIR}" "${PHASE126_DIR}"
|
||||
: >"${SUMMARY}"
|
||||
|
||||
write_summary() {
|
||||
echo "$*" | tee -a "${SUMMARY}" >/dev/null
|
||||
}
|
||||
|
||||
summary_value() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
awk -F= -v key="$key" '$1 == key {value = substr($0, length(key) + 2)} END {if (value != "") print value}' "$file"
|
||||
}
|
||||
|
||||
require_summary_value() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
local value
|
||||
value="$(summary_value "$file" "$key")"
|
||||
if [[ -z "${value}" ]]; then
|
||||
echo "missing summary key ${key} in ${file}" >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s' "${value}"
|
||||
}
|
||||
|
||||
assert_int_ge() {
|
||||
local actual="$1"
|
||||
local want="$2"
|
||||
local label="$3"
|
||||
python3 - "$actual" "$want" "$label" <<'PY'
|
||||
import sys
|
||||
actual = int(sys.argv[1])
|
||||
want = int(sys.argv[2])
|
||||
label = sys.argv[3]
|
||||
if actual < want:
|
||||
raise SystemExit(f"{label}={actual}, want >= {want}")
|
||||
PY
|
||||
}
|
||||
|
||||
assert_int_lt() {
|
||||
local actual="$1"
|
||||
local want="$2"
|
||||
local label="$3"
|
||||
python3 - "$actual" "$want" "$label" <<'PY'
|
||||
import sys
|
||||
actual = int(sys.argv[1])
|
||||
want = int(sys.argv[2])
|
||||
label = sys.argv[3]
|
||||
if actual >= want:
|
||||
raise SystemExit(f"{label}={actual}, want < {want}")
|
||||
PY
|
||||
}
|
||||
|
||||
write_summary "phase134_durable_backend_write_batching_status=running"
|
||||
write_summary "frontend_transport=tcp"
|
||||
write_summary "roce_claim_allowed=false"
|
||||
write_summary "nvme_rdma_claim_allowed=false"
|
||||
write_summary "performance_slo_claim_allowed=false"
|
||||
write_summary "batch_scope=contiguous_full_block_writes"
|
||||
write_summary "batch_max_blocks=64"
|
||||
|
||||
cd "${ROOT}"
|
||||
go test ./core/frontend/durable ./core/storage/... \
|
||||
>"${ARTIFACT_DIR}/go-test-durable-storage.log" \
|
||||
2>&1
|
||||
write_summary "unit_batch_regression_passed=true"
|
||||
write_summary "strict_ack_batch_disabled=true"
|
||||
write_summary "read_after_write_regression_passed=true"
|
||||
|
||||
SW_BLOCK_ARTIFACT_DIR="${PHASE126_DIR}" \
|
||||
SW_BLOCK_PHASE126_SEQ_MIB="${SEQ_MIB}" \
|
||||
bash "${ROOT}/scripts/run-phase126-block-nvme-tcp-backend-write-instrumentation-gate.sh" "${ROOT}" \
|
||||
>"${ARTIFACT_DIR}/phase126-profile.stdout.txt" \
|
||||
2>"${ARTIFACT_DIR}/phase126-profile.stderr.txt"
|
||||
|
||||
PHASE126_SUMMARY="${PHASE126_DIR}/phase126-block-nvme-tcp-backend-write-instrumentation-summary.txt"
|
||||
if [[ "$(require_summary_value "${PHASE126_SUMMARY}" phase126_block_nvme_tcp_backend_write_instrumentation_status)" != "ok" ]]; then
|
||||
echo "phase126 profile dependency did not finish ok" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGET_OBSERVED="$(require_summary_value "${PHASE126_SUMMARY}" target_write_observed)"
|
||||
TARGET_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" target_write_bytes)"
|
||||
BACKEND_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" backend_write_bytes)"
|
||||
BACKEND_OPS="$(require_summary_value "${PHASE126_SUMMARY}" backend_write_ops)"
|
||||
BACKEND_MS="$(require_summary_value "${PHASE126_SUMMARY}" backend_write_duration_ms)"
|
||||
BACKEND_STORAGE_WRITE_CALLS="$(require_summary_value "${PHASE126_SUMMARY}" backend_storage_write_calls)"
|
||||
BACKEND_STORAGE_WRITE_BLOCKS="$(require_summary_value "${PHASE126_SUMMARY}" backend_storage_write_blocks)"
|
||||
BACKEND_STORAGE_BATCH_CALLS="$(require_summary_value "${PHASE126_SUMMARY}" backend_storage_batch_calls)"
|
||||
BACKEND_STORAGE_BATCH_BLOCKS="$(require_summary_value "${PHASE126_SUMMARY}" backend_storage_batch_blocks)"
|
||||
SYNC_OPS="$(require_summary_value "${PHASE126_SUMMARY}" backend_sync_ops)"
|
||||
CLEANUP_STATUS="$(require_summary_value "${PHASE126_SUMMARY}" cleanup_status)"
|
||||
|
||||
if [[ "${TARGET_OBSERVED}" != "true" ]]; then
|
||||
echo "target_write_observed=${TARGET_OBSERVED}, want true" >&2
|
||||
exit 1
|
||||
fi
|
||||
assert_int_ge "${TARGET_BYTES}" 1 "target_write_bytes"
|
||||
assert_int_ge "${BACKEND_BYTES}" 1 "backend_write_bytes"
|
||||
assert_int_ge "${BACKEND_OPS}" 1 "backend_write_ops"
|
||||
assert_int_ge "${BACKEND_STORAGE_WRITE_CALLS}" 1 "backend_storage_write_calls"
|
||||
assert_int_ge "${BACKEND_STORAGE_WRITE_BLOCKS}" 2 "backend_storage_write_blocks"
|
||||
assert_int_ge "${BACKEND_STORAGE_BATCH_CALLS}" 1 "backend_storage_batch_calls"
|
||||
assert_int_ge "${BACKEND_STORAGE_BATCH_BLOCKS}" 2 "backend_storage_batch_blocks"
|
||||
assert_int_lt "${BACKEND_STORAGE_WRITE_CALLS}" "${BACKEND_STORAGE_WRITE_BLOCKS}" "backend_storage_write_calls"
|
||||
if [[ "${CLEANUP_STATUS}" != "ok" ]]; then
|
||||
echo "cleanup_status=${CLEANUP_STATUS}, want ok" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
write_summary "target_write_observed=${TARGET_OBSERVED}"
|
||||
write_summary "target_write_bytes=${TARGET_BYTES}"
|
||||
write_summary "backend_write_bytes=${BACKEND_BYTES}"
|
||||
write_summary "backend_write_ops=${BACKEND_OPS}"
|
||||
write_summary "backend_write_duration_ms=${BACKEND_MS}"
|
||||
write_summary "backend_storage_write_calls=${BACKEND_STORAGE_WRITE_CALLS}"
|
||||
write_summary "backend_storage_write_blocks=${BACKEND_STORAGE_WRITE_BLOCKS}"
|
||||
write_summary "backend_storage_batch_calls=${BACKEND_STORAGE_BATCH_CALLS}"
|
||||
write_summary "backend_storage_batch_blocks=${BACKEND_STORAGE_BATCH_BLOCKS}"
|
||||
write_summary "backend_storage_batching_effective=true"
|
||||
write_summary "backend_sync_ops=${SYNC_OPS}"
|
||||
write_summary "cleanup_status=${CLEANUP_STATUS}"
|
||||
write_summary "phase134_durable_backend_write_batching_status=ok"
|
||||
@@ -0,0 +1,111 @@
|
||||
name: nvme-tcp-durable-backend-write-batching-chain
|
||||
timeout: 90m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "helm status sw-block --namespace kube-system >/dev/null 2>&1 && helm uninstall sw-block --namespace kube-system --wait --timeout 240s || true; kubectl -n default delete pod sw-block-phase126-block-perf sw-block-phase126-local-perf --ignore-not-found=true --wait=true --timeout=60s || true; kubectl -n default delete pvc sw-block-phase126-block-pvc sw-block-phase126-local-pvc --ignore-not-found=true --wait=true --timeout=60s || true; kubectl delete storageclass sw-block-phase126-block --ignore-not-found=true --wait=true --timeout=60s || true; kubectl get pv --no-headers | awk '/sw-block-phase126/ {print $1}' | xargs -r -n1 kubectl patch pv --type=merge -p '{\"metadata\":{\"finalizers\":[]}}' >/dev/null 2>&1 || true; kubectl get pv --no-headers | awk '/sw-block-phase126/ {print $1}' | xargs -r kubectl delete pv --wait=false >/dev/null 2>&1 || true; kubectl -n kube-system get swblockvolumes.block.seaweedfs.com -o name 2>/dev/null | xargs -r -n1 kubectl -n kube-system patch --type=merge -p '{\"metadata\":{\"finalizers\":[]}}' >/dev/null 2>&1 || true; kubectl -n kube-system delete swblockvolumes.block.seaweedfs.com --all --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1 || true; kubectl -n kube-system delete swblockclusters.block.seaweedfs.com --all --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1 || true; kubectl delete validatingadmissionpolicy,validatingadmissionpolicybinding -l app.kubernetes.io/instance=sw-block --ignore-not-found=true >/dev/null 2>&1 || true; kubectl delete crd swblockclusters.block.seaweedfs.com swblockvolumes.block.seaweedfs.com swblockreplicaeligibilities.block.seaweedfs.com swblockreplicarebuilds.block.seaweedfs.com swblockreplicafailbacks.block.seaweedfs.com swblockfrontendpublications.block.seaweedfs.com --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1 || true; sudo -n nvme disconnect-all >/dev/null 2>&1 || true; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: run_gate
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 82m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching SW_BLOCK_PHASE134_SEQ_MIB=64 SW_BLOCK_PHASE125_FRONTEND_IP_MAP=m01=10.0.0.1,m02=10.0.0.3 SW_BLOCK_PHASE125_EXPECTED_ROUTE_DEV=enp1s0np0 SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key bash scripts/run-phase134-durable-backend-write-batching-gate.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: assert_summary
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching/phase134-durable-backend-write-batching-summary.txt"
|
||||
pattern: "^phase134_durable_backend_write_batching_status=ok$"
|
||||
save_as: phase134_status_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ phase134_status_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching/phase134-durable-backend-write-batching-summary.txt"
|
||||
pattern: "^unit_batch_regression_passed=true$"
|
||||
save_as: unit_passed
|
||||
- action: assert_greater
|
||||
actual: "{{ unit_passed }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching/phase134-durable-backend-write-batching-summary.txt"
|
||||
pattern: "^strict_ack_batch_disabled=true$"
|
||||
save_as: strict_ack_guard
|
||||
- action: assert_greater
|
||||
actual: "{{ strict_ack_guard }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching/phase134-durable-backend-write-batching-summary.txt"
|
||||
pattern: "^target_write_observed=true$"
|
||||
save_as: target_observed
|
||||
- action: assert_greater
|
||||
actual: "{{ target_observed }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching/phase134-durable-backend-write-batching-summary.txt"
|
||||
pattern: "^backend_storage_batch_calls=[1-9][0-9]*$"
|
||||
save_as: batch_calls
|
||||
- action: assert_greater
|
||||
actual: "{{ batch_calls }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching/phase134-durable-backend-write-batching-summary.txt"
|
||||
pattern: "^backend_storage_batch_blocks=[1-9][0-9]*$"
|
||||
save_as: batch_blocks
|
||||
- action: assert_greater
|
||||
actual: "{{ batch_blocks }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching/phase134-durable-backend-write-batching-summary.txt"
|
||||
pattern: "^backend_storage_batching_effective=true$"
|
||||
save_as: batching_effective
|
||||
- action: assert_greater
|
||||
actual: "{{ batching_effective }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching/phase134-durable-backend-write-batching-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: cleanup_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ cleanup_ok }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: collect
|
||||
always: true
|
||||
actions:
|
||||
- action: collect_path
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase134-write-batching"
|
||||
name: "remote-phases"
|
||||
ignore_error: true
|
||||
Reference in new issue
Block a user