Files
seaweedfs/weed/storage/blockvol/v2bridge/executor.go
T
pingqiuandClaude Opus 4.6 785a7d7efd feat: wire real pinner into flusher retention + real WAL scan executor (Phase 07 P1)
Pinner wired to real retention:
- NewPinner calls vol.SetV2RetentionFloor(p.MinWALRetentionFloor)
- Flusher.RetentionFloorFn() / SetRetentionFloorFn() exposed
- SetV2RetentionFloor chains with existing shipper retention floor
- Holds actually prevent WAL reclaim (not just tracked state)

Executor uses real WAL scan:
- BlockVol.ScanWALEntries(fromLSN, callback) wraps wal.ScanFrom
  with real fd, walOffset, checkpointLSN
- Executor.StreamWALEntries uses ScanWALEntries (not stub)
- Reads real WAL entries, tracks highest LSN scanned

CommittedLSN mapping:
- Explicitly documented as interim V1 model (committed = checkpointed)
- Will diverge when V2 distributed commit separates from local flush

Carry-forward:
- TransferSnapshot/TransferFullBase/TruncateWAL: stubs (need extent I/O)
- Control intent from confirmed failover: deferred

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 20:01:46 -07:00

65 lines
2.0 KiB
Go

package v2bridge
import (
"fmt"
"github.com/seaweedfs/seaweedfs/weed/storage/blockvol"
)
// Executor performs real recovery I/O using blockvol internals.
// It executes what the engine tells it to do — it does NOT decide
// recovery policy.
//
// Phase 07 P1: one narrow path (WAL catch-up streaming).
// Full-base rebuild and snapshot transfer are deferred.
type Executor struct {
vol *blockvol.BlockVol
}
// NewExecutor creates an executor for a real blockvol instance.
func NewExecutor(vol *blockvol.BlockVol) *Executor {
return &Executor{vol: vol}
}
// StreamWALEntries reads WAL entries from startExclusive+1 to endInclusive
// using BlockVol.ScanWALEntries (real ScanFrom mechanism).
// Returns the highest LSN successfully scanned.
//
// This is the real catch-up data path. The callback receives each entry
// for shipping to the replica (network-layer apply is the caller's job).
func (e *Executor) StreamWALEntries(startExclusive, endInclusive uint64) (uint64, error) {
if e.vol == nil {
return 0, fmt.Errorf("no blockvol instance")
}
var highestLSN uint64
err := e.vol.ScanWALEntries(startExclusive+1, func(entry *blockvol.WALEntry) error {
if entry.LSN > endInclusive {
return nil // past requested range, stop
}
// In production: ship entry to replica over network.
// Here: track the highest LSN successfully read.
highestLSN = entry.LSN
return nil
})
if err != nil {
return highestLSN, fmt.Errorf("WAL scan from %d: %w", startExclusive, err)
}
return highestLSN, nil
}
// TransferSnapshot transfers a checkpoint/snapshot. Stub for P1.
func (e *Executor) TransferSnapshot(snapshotLSN uint64) error {
return fmt.Errorf("TransferSnapshot not implemented in P1")
}
// TransferFullBase transfers the full extent image. Stub for P1.
func (e *Executor) TransferFullBase(committedLSN uint64) error {
return fmt.Errorf("TransferFullBase not implemented in P1")
}
// TruncateWAL removes entries beyond truncateLSN. Stub for P1.
func (e *Executor) TruncateWAL(truncateLSN uint64) error {
return fmt.Errorf("TruncateWAL not implemented in P1")
}