mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
test(durable): retain terminal stop semantics for queued pre-copy I/O
This commit is contained in:
1 parent
e0fe4f72fe
commit
1f4a2d2ad2
2 files changed
+58
-2
No files matched your search
@@ -102,3 +102,59 @@ func TestPrecopyFreezeCallerDeadlineIsRetryable(t *testing.T) {
|
||||
t.Fatalf("deadline lost retryable admission status: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrecopyFreezeTerminalStopWakesQueuedIO(t *testing.T) {
|
||||
for _, terminal := range []string{"close", "stop"} {
|
||||
t.Run(terminal, func(t *testing.T) {
|
||||
p := precopyProvider(t, storage.NewMemChunkRemote(), &parkView{stubView: v1View()})
|
||||
openRecovered(t, p)
|
||||
b, err := p.Open(context.Background(), "v1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
gate := b.(interface {
|
||||
TryStopIO(string) bool
|
||||
SetOperational(bool, string)
|
||||
})
|
||||
if !gate.TryStopIO("pre-copy final cut") {
|
||||
t.Fatal("freeze failed")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
started, done := make(chan struct{}), make(chan struct{})
|
||||
var result error
|
||||
t.Cleanup(func() {
|
||||
cancel()
|
||||
gate.SetOperational(false, "cleanup")
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Error("queued command did not join")
|
||||
}
|
||||
})
|
||||
go func() { defer close(done); close(started); _, result = b.Write(ctx, 4096, block(9)) }()
|
||||
<-started
|
||||
select {
|
||||
case <-done:
|
||||
t.Fatalf("command escaped freeze: %v", result)
|
||||
case <-time.After(30 * time.Millisecond):
|
||||
}
|
||||
want := frontend.ErrNotReady
|
||||
if terminal == "close" {
|
||||
want = frontend.ErrBackendClosed
|
||||
if err := b.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
gate.SetOperational(false, "workspace lease self-fence")
|
||||
}
|
||||
select {
|
||||
case <-done:
|
||||
if !errors.Is(result, want) || errors.Is(result, frontend.ErrBackendBusy) {
|
||||
t.Fatalf("terminal gate masked: %v", result)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("terminal stop did not wake command")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -162,8 +162,8 @@ type StorageBackend struct {
|
||||
// false; provider flips true after Recover() succeeds (T3b).
|
||||
// opEvidence is the reason reported when operational=false
|
||||
// (e.g., "awaiting recovery", "local epoch ahead of assignment").
|
||||
// Only a successfully recovered chunk volume awaiting attachment may wait.
|
||||
// waitAttachReady and readyChanged are protected by mu.
|
||||
// Readiness waits cover pending chunk attachment and temporary pre-copy freezes.
|
||||
// Readiness flags and readyChanged are protected by mu.
|
||||
waitAttachReady bool
|
||||
waitPrecopyReady bool // temporary pre-copy freeze; queued I/O has not reached storage
|
||||
readyChanged chan struct{}
|
||||
|
||||
Reference in new issue
Block a user