mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
storage: bind dark v3 WAL writer and scan to nonce and logical cursor
This commit is contained in:
1 parent
f031f03d1b
commit
7fb5e8798c
2 files changed
+524
No files matched your search
@@ -0,0 +1,276 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sort"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var errWALBindingV3 = errors.New("storage: v3 WAL nonce/cursor binding refused")
|
||||
|
||||
// walSnapshotV3 takes the descriptor and its reuse floor in one snapshot.
|
||||
// It releases descMu before any writer lock, pwrite or callback is acquired.
|
||||
func (p *descriptorPublisherV3) walSnapshotV3() (descriptorV3, uint64, bool) {
|
||||
p.descMu.Lock()
|
||||
defer p.descMu.Unlock()
|
||||
floor, ok := p.reuseFloorLocked()
|
||||
return p.cur, floor, ok
|
||||
}
|
||||
|
||||
// walWriterV3 is dark until activation. Its caller serializes store changes,
|
||||
// supplies the frozen acknowledged frontier for DurableLSN, and admits appends
|
||||
// only after recovery/fence/head publication (rows 5/11). It performs pwrite,
|
||||
// not Sync. A pwrite failure is terminal here and must also latch the store's
|
||||
// append fault when integrated. No descriptor publication is hidden in append.
|
||||
type walWriterV3 struct {
|
||||
mu sync.Mutex
|
||||
pub *descriptorPublisherV3
|
||||
fd *os.File
|
||||
nonce [16]byte
|
||||
head uint64
|
||||
failed error
|
||||
writeAt func([]byte, int64) (int, error)
|
||||
}
|
||||
|
||||
func newWALWriterV3(fd *os.File, pub *descriptorPublisherV3) (*walWriterV3, error) {
|
||||
d, _, ok := pub.walSnapshotV3()
|
||||
if err := d.validate(pub.accept); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !ok || d.MigrationPhase != MigrationNormal {
|
||||
return nil, errWALBindingV3
|
||||
}
|
||||
return &walWriterV3{pub: pub, fd: fd, nonce: d.Nonce, head: d.RetainedHead, writeAt: fd.WriteAt}, nil
|
||||
}
|
||||
|
||||
func (w *walWriterV3) append(e walEntryV3, durableLSN uint64) (uint64, error) {
|
||||
// Descriptor snapshot precedes the writer lock. A concurrent floor advance
|
||||
// makes this snapshot conservative; reset must quiesce/recreate the writer.
|
||||
d, floor, ok := w.pub.walSnapshotV3()
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
if w.failed != nil {
|
||||
return 0, w.failed
|
||||
}
|
||||
if err := w.pub.io.sticky(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if !ok || d.Nonce != w.nonce || w.head < floor || w.head-floor > d.WALSize {
|
||||
return 0, errWALBindingV3
|
||||
}
|
||||
e.Nonce = w.nonce
|
||||
e.LogicalStart = w.head
|
||||
e.DurableLSN = durableLSN
|
||||
n, err := e.payloadSizeV3(d.BlockSize, d.VolumeSize/uint64(d.BlockSize))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
size := uint64(walEntryHeaderSizeV3) + n
|
||||
if size > d.WALSize {
|
||||
return 0, errWALFull
|
||||
}
|
||||
remaining := d.WALSize - w.head%d.WALSize
|
||||
gap := uint64(0)
|
||||
if size > remaining {
|
||||
gap = remaining
|
||||
}
|
||||
if gap > counterMaxV3-w.head || size > counterMaxV3-w.head-gap {
|
||||
return 0, ErrCounterExhausted
|
||||
}
|
||||
free := d.WALSize - (w.head - floor)
|
||||
if gap > free || size > free-gap {
|
||||
return 0, errWALFull
|
||||
}
|
||||
start := w.head + gap
|
||||
e.LogicalStart = start
|
||||
buf, err := encodeWALEntryV3(e, d.BlockSize, d.VolumeSize/uint64(d.BlockSize))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var pad []byte
|
||||
if gap >= walEntryHeaderSizeV3 {
|
||||
if gap-walEntryHeaderSizeV3 > uint64(^uint32(0)) {
|
||||
return 0, errWALFull
|
||||
}
|
||||
pad, err = encodeWALEntryV3(walEntryV3{Type: walEntryPadding, Length: uint32(gap - walEntryHeaderSizeV3), LogicalStart: w.head, Nonce: w.nonce, Data: make([]byte, int(gap-walEntryHeaderSizeV3))}, d.BlockSize, d.VolumeSize/uint64(d.BlockSize))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
write := func(b []byte, pos uint64) error {
|
||||
n, err := w.writeAt(b, int64(d.WALOffset+pos%d.WALSize))
|
||||
if err == nil && n != len(b) {
|
||||
err = io.ErrShortWrite
|
||||
}
|
||||
if err != nil {
|
||||
w.failed = fmt.Errorf("%w: v3 append: %w", errWALPwrite, err)
|
||||
return w.failed
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if len(pad) > 0 {
|
||||
if err := write(pad, w.head); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
// A suffix shorter than 70 is skipped geometrically, never decoded as a record.
|
||||
if err := write(buf, start); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
w.head = start + size
|
||||
return start % d.WALSize, nil
|
||||
}
|
||||
|
||||
func (w *walWriterV3) logicalHeadV3() uint64 { w.mu.Lock(); defer w.mu.Unlock(); return w.head }
|
||||
|
||||
// restoreScanV3 restores only the validated cursor. It does not grant admission:
|
||||
// the owner must complete the durable drop fence and descriptor publication
|
||||
// before another append. No ring/nonce reset or floor waiver occurs here.
|
||||
func (w *walWriterV3) restoreScanV3(r walScanResultV3) error {
|
||||
d, floor, ok := w.pub.walSnapshotV3()
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
if !ok || r.Nonce != w.nonce || d.Nonce != w.nonce || r.End < floor || r.End-floor > d.WALSize {
|
||||
return errWALBindingV3
|
||||
}
|
||||
if r.End > counterMaxV3 {
|
||||
return ErrCounterExhausted
|
||||
}
|
||||
w.head = r.End
|
||||
return nil
|
||||
}
|
||||
|
||||
type walScannedRecordV3 struct {
|
||||
Entry walEntryV3
|
||||
End uint64
|
||||
}
|
||||
|
||||
// walScanResultV3 is a read-only scan result, not a ready/ACK permission.
|
||||
// Row 5 consumes Frontier/MaxDurableLSN for R<W* and performs fence/publication
|
||||
// before replay/admission. StopCause describes the first untrusted tail record;
|
||||
// it cannot be used to skip that record and resume searching inside payload.
|
||||
type walScanResultV3 struct {
|
||||
Nonce [16]byte
|
||||
Start, End uint64
|
||||
Frontier, HighestLSN, MaxDurableLSN uint64
|
||||
Records []walScannedRecordV3
|
||||
StopCause error
|
||||
}
|
||||
|
||||
func scanWALV3(fd io.ReaderAt, d descriptorV3) (walScanResultV3, error) {
|
||||
r := walScanResultV3{Nonce: d.Nonce}
|
||||
if err := d.validate(nil); err != nil {
|
||||
return r, err
|
||||
}
|
||||
if d.MigrationPhase != MigrationNormal {
|
||||
return r, ErrMigrationIncomplete
|
||||
}
|
||||
if d.WALSize > counterMaxV3-d.RetainedTail {
|
||||
return r, ErrCounterExhausted
|
||||
}
|
||||
limit := d.RetainedTail + d.WALSize
|
||||
start := d.RetainedTail
|
||||
base := d.CheckpointLSN
|
||||
if d.BaseState != BaseNone {
|
||||
start = max(start, d.BaseCursor)
|
||||
base = max(base, d.BaseLSN)
|
||||
}
|
||||
r.Start = start
|
||||
r.End = start
|
||||
r.Frontier = base
|
||||
r.HighestLSN = base
|
||||
for cursor := start; cursor < limit; {
|
||||
remaining := d.WALSize - cursor%d.WALSize
|
||||
if remaining < walEntryHeaderSizeV3 {
|
||||
if remaining > limit-cursor {
|
||||
break
|
||||
}
|
||||
cursor += remaining
|
||||
r.End = cursor
|
||||
continue
|
||||
}
|
||||
if limit-cursor < walEntryHeaderSizeV3 {
|
||||
break
|
||||
}
|
||||
header := make([]byte, walEntryPrefixSizeV3)
|
||||
if _, err := fd.ReadAt(header, int64(d.WALOffset+cursor%d.WALSize)); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
r.StopCause = errEntryTruncated
|
||||
break
|
||||
}
|
||||
return r, err
|
||||
}
|
||||
// Check the binding BEFORE using attacker-controlled Length or count.
|
||||
le := binary.LittleEndian
|
||||
var nonce [16]byte
|
||||
copy(nonce[:], header[46:62])
|
||||
if nonce != d.Nonce || le.Uint64(header[38:46]) != cursor {
|
||||
r.StopCause = errWALBindingV3
|
||||
break
|
||||
}
|
||||
e := walEntryV3{LSN: le.Uint64(header[0:8]), BatchCount: le.Uint64(header[8:16]), Type: header[16], Flags: header[17], LBA: le.Uint64(header[18:26]), Length: le.Uint32(header[26:30]), DurableLSN: le.Uint64(header[30:38]), LogicalStart: cursor, Nonce: nonce}
|
||||
n, err := e.payloadSizeV3(d.BlockSize, d.VolumeSize/uint64(d.BlockSize))
|
||||
if err != nil {
|
||||
r.StopCause = err
|
||||
break
|
||||
}
|
||||
size := uint64(walEntryHeaderSizeV3) + n
|
||||
if size > remaining || size > limit-cursor {
|
||||
r.StopCause = errEntryTruncated
|
||||
break
|
||||
}
|
||||
buf := make([]byte, int(size))
|
||||
if _, err := fd.ReadAt(buf, int64(d.WALOffset+cursor%d.WALSize)); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
r.StopCause = errEntryTruncated
|
||||
break
|
||||
}
|
||||
return r, err
|
||||
}
|
||||
e, err = decodeWALEntryV3(buf, d.BlockSize, d.VolumeSize/uint64(d.BlockSize))
|
||||
if err != nil {
|
||||
r.StopCause = err
|
||||
break
|
||||
}
|
||||
if e.Nonce != d.Nonce || e.LogicalStart != cursor || uint64(walEntryHeaderSizeV3+len(e.Data)) != size {
|
||||
r.StopCause = errWALBindingV3
|
||||
break
|
||||
}
|
||||
cursor += size
|
||||
r.End = cursor
|
||||
if e.Type == walEntryPadding {
|
||||
continue
|
||||
}
|
||||
r.MaxDurableLSN = max(r.MaxDurableLSN, e.DurableLSN)
|
||||
last := e.LSN
|
||||
if e.Type == walEntryWriteBatch {
|
||||
last += e.BatchCount - 1
|
||||
}
|
||||
r.HighestLSN = max(r.HighestLSN, last)
|
||||
r.Records = append(r.Records, walScannedRecordV3{Entry: e, End: cursor})
|
||||
}
|
||||
// LSN interval union, not an expansion proportional to an untrusted LSN gap
|
||||
// or batch count. Record geometry and endpoints have already been validated.
|
||||
type interval struct{ first, last uint64 }
|
||||
spans := make([]interval, 0, len(r.Records))
|
||||
for _, record := range r.Records {
|
||||
e := record.Entry
|
||||
last := e.LSN
|
||||
if e.Type == walEntryWriteBatch {
|
||||
last += e.BatchCount - 1
|
||||
}
|
||||
spans = append(spans, interval{e.LSN, last})
|
||||
}
|
||||
sort.Slice(spans, func(i, j int) bool { return spans[i].first < spans[j].first })
|
||||
for _, span := range spans {
|
||||
if r.Frontier == counterMaxV3 || span.first > r.Frontier+1 {
|
||||
break
|
||||
}
|
||||
r.Frontier = max(r.Frontier, span.last)
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"hash/crc32"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// A real file with row-1 slots and row-3 publisher; no v2 constructor or
|
||||
// legacy recovery scanner is used by this dark writer/scanner harness.
|
||||
func newWALIOTestV3(t *testing.T, head, tail uint64) (*os.File, *descriptorPublisherV3, *walWriterV3) {
|
||||
t.Helper()
|
||||
d, err := decodeSlotV3(readSlotVector(t, "slot-ref"), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d.WALSize = 16 * 1024
|
||||
d.RetainedHead = head
|
||||
d.RetainedTail = tail
|
||||
d.W = 0
|
||||
d.CheckpointLSN = 0
|
||||
d.MapCoveredCheckpoint = 0
|
||||
d.BaseState = BaseNone
|
||||
d.BaseLSN = 0
|
||||
d.BaseCursor = 0
|
||||
d.BaseInstallID = [16]byte{}
|
||||
f, err := os.Create(filepath.Join(t.TempDir(), "store.v3"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = f.Close() })
|
||||
if err := f.Truncate(int64(d.WALOffset + d.WALSize + d.VolumeSize)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := f.WriteAt(d.encode(), slotAOffsetV3); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var leaf sync.Mutex
|
||||
pub := newDescriptorPublisherV3(d, slotA, nil, descriptorIOV3{
|
||||
writeSlot: func(off int64, b []byte) error {
|
||||
n, e := f.WriteAt(b, off)
|
||||
if e == nil && n != len(b) {
|
||||
return io.ErrShortWrite
|
||||
}
|
||||
return e
|
||||
},
|
||||
fsync: f.Sync, sticky: func() error { return nil },
|
||||
syncFile: func(write, sync func() error) error {
|
||||
leaf.Lock()
|
||||
defer leaf.Unlock()
|
||||
if err := write(); err != nil {
|
||||
return err
|
||||
}
|
||||
return sync()
|
||||
},
|
||||
})
|
||||
w, err := newWALWriterV3(f, pub)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return f, pub, w
|
||||
}
|
||||
|
||||
func TestWALIOV3_RealWriterReopenScan(t *testing.T) {
|
||||
f, p, w := newWALIOTestV3(t, 0, 0)
|
||||
d := p.current()
|
||||
for i := uint64(1); i <= 3; i++ {
|
||||
e := walEntryV3{LSN: i, Type: walEntryWrite, LBA: i, Length: d.BlockSize, Data: bytes.Repeat([]byte{byte(i)}, int(d.BlockSize))}
|
||||
// Caller binding fields are overwritten, not trusted.
|
||||
e.Nonce = [16]byte{0xFF}
|
||||
e.LogicalStart = 999
|
||||
if _, err := w.append(e, i-1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := f.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Close/reopen is real; slots still lag the appends, as in mode C.
|
||||
name := f.Name()
|
||||
if err := f.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rfd, err := os.Open(name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer rfd.Close()
|
||||
r, err := scanWALV3(rfd, d)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(r.Records) != 3 || r.Frontier != 3 || r.HighestLSN != 3 || r.MaxDurableLSN != 2 || r.End != w.logicalHeadV3() {
|
||||
t.Fatalf("validated scan=%+v", r)
|
||||
}
|
||||
for i, record := range r.Records {
|
||||
e := record.Entry
|
||||
if e.Nonce != d.Nonce || e.LogicalStart != uint64(i)*(uint64(d.BlockSize)+70) || !bytes.Equal(e.Data, bytes.Repeat([]byte{byte(i + 1)}, int(d.BlockSize))) {
|
||||
t.Fatal("writer/scanner binding or payload mismatch")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWALIOV3_WrapPaddingAndSlack(t *testing.T) {
|
||||
for _, remaining := range []uint64{32, 70, 130} {
|
||||
t.Run(map[uint64]string{32: "geometric slack", 70: "empty padding", 130: "payload padding"}[remaining], func(t *testing.T) {
|
||||
const size = 16 * 1024
|
||||
start := uint64(size) - remaining
|
||||
f, p, w := newWALIOTestV3(t, start, start)
|
||||
d := p.current()
|
||||
if _, err := w.append(walEntryV3{LSN: 1, Type: walEntryWrite, LBA: 1, Length: d.BlockSize, Data: make([]byte, d.BlockSize)}, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := f.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, err := scanWALV3(f, d)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(r.Records) != 1 || r.Records[0].Entry.LogicalStart != size || r.Frontier != 1 || r.End != size+70+uint64(d.BlockSize) {
|
||||
t.Fatalf("wrapped scan=%+v", r)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWALIOV3_StopsAtBindingBeforeEmbeddedRecord(t *testing.T) {
|
||||
for _, kind := range []string{"foreign nonce", "wrong cursor same lap", "old lap", "bad CRC", "bad footer"} {
|
||||
t.Run(kind, func(t *testing.T) {
|
||||
f, p, _ := newWALIOTestV3(t, 0, 0)
|
||||
d := p.current()
|
||||
// A valid barrier is hidden after the first header. The scanner must not
|
||||
// search onward for it after failing the first record's admission.
|
||||
good, err := encodeWALEntryV3(walEntryV3{LSN: 1, Type: walEntryBarrier, Nonce: d.Nonce}, d.BlockSize, d.VolumeSize/uint64(d.BlockSize))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b := bytes.Clone(good)
|
||||
switch kind {
|
||||
case "foreign nonce":
|
||||
b[46] ^= 1
|
||||
case "wrong cursor same lap":
|
||||
binary.LittleEndian.PutUint64(b[38:46], 70)
|
||||
case "old lap":
|
||||
binary.LittleEndian.PutUint64(b[38:46], d.WALSize)
|
||||
case "bad CRC":
|
||||
b[62] ^= 1
|
||||
case "bad footer":
|
||||
b[66] ^= 1
|
||||
}
|
||||
if kind != "bad CRC" && kind != "bad footer" {
|
||||
binary.LittleEndian.PutUint32(b[62:66], crc32.Checksum(b[:62], walEntryCRC32CV3))
|
||||
}
|
||||
hidden := bytes.Clone(good)
|
||||
binary.LittleEndian.PutUint64(hidden[38:46], 70)
|
||||
binary.LittleEndian.PutUint32(hidden[62:66], crc32.Checksum(hidden[:62], walEntryCRC32CV3))
|
||||
if _, err := f.WriteAt(append(b, hidden...), int64(d.WALOffset)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, err := scanWALV3(f, d)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(r.Records) != 0 || r.End != 0 || r.MaxDurableLSN != 0 || r.StopCause == nil {
|
||||
t.Fatalf("untrusted/embedded record admitted: %+v", r)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWALIOV3_InstalledScanBeginsAtMaxTail(t *testing.T) {
|
||||
f, p, w := newWALIOTestV3(t, 140, 140)
|
||||
d := p.current()
|
||||
d.BaseState = BaseInstalled
|
||||
d.BaseInstallID = [16]byte{1}
|
||||
d.BaseCursor = 70
|
||||
d.BaseLSN = 5
|
||||
d.CheckpointLSN = 5
|
||||
d.W = 5
|
||||
d.MapCoveredCheckpoint = 5
|
||||
if _, err := w.append(walEntryV3{LSN: 6, Type: walEntryBarrier}, 5); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, err := scanWALV3(f, d)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r.Start != 140 || r.End != 210 || r.Frontier != 6 || len(r.Records) != 1 {
|
||||
t.Fatalf("max-tail scan=%+v", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWALIOV3_ValidatedFrontierIntervals(t *testing.T) {
|
||||
f, p, w := newWALIOTestV3(t, 0, 0)
|
||||
d := p.current()
|
||||
// A gap above BASE must remain a gap; no allocation proportional to LSN.
|
||||
d.BaseState = BaseInstalling
|
||||
d.BaseInstallID = [16]byte{1}
|
||||
d.BaseLSN = 100
|
||||
for _, lsn := range []uint64{102, 101, 104} {
|
||||
if _, err := w.append(walEntryV3{LSN: lsn, Type: walEntryBarrier}, 100); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
r, err := scanWALV3(f, d)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r.Frontier != 102 || r.HighestLSN != 104 || r.MaxDurableLSN != 100 || len(r.Records) != 3 {
|
||||
t.Fatalf("interval scan=%+v", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWALIOV3_FloorAndPwriteFailureRefuse(t *testing.T) {
|
||||
f, p, w := newWALIOTestV3(t, 16*1024, 0)
|
||||
_ = f
|
||||
before := w.logicalHeadV3()
|
||||
if _, err := w.append(walEntryV3{LSN: 1, Type: walEntryBarrier}, 0); !errors.Is(err, errWALFull) {
|
||||
t.Fatalf("full ring error=%v", err)
|
||||
}
|
||||
if w.logicalHeadV3() != before {
|
||||
t.Fatal("full append changed writer head")
|
||||
}
|
||||
if _, err := p.publish(nil, nil, func(d *descriptorV3) error { d.RetainedTail = 16 * 1024; return nil }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := w.append(walEntryV3{LSN: 1, Type: walEntryBarrier}, 0); !errors.Is(err, errWALFull) {
|
||||
t.Fatalf("fallback tail must still pin: %v", err)
|
||||
}
|
||||
if ok, err := p.rolloverIfPinned(); err != nil || !ok {
|
||||
t.Fatalf("rollover=%v %v", ok, err)
|
||||
}
|
||||
calls := 0
|
||||
w.writeAt = func(b []byte, off int64) (int, error) { calls++; return 1, io.ErrShortWrite }
|
||||
if _, err := w.append(walEntryV3{LSN: 1, Type: walEntryBarrier}, 0); !errors.Is(err, errWALPwrite) {
|
||||
t.Fatalf("append failure=%v", err)
|
||||
}
|
||||
if _, err := w.append(walEntryV3{LSN: 1, Type: walEntryBarrier}, 0); !errors.Is(err, errWALPwrite) || calls != 1 {
|
||||
t.Fatal("failed append retried physical I/O")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user