mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
test(chunk): witness every scheduler stopper joining its worker
This commit is contained in:
1 parent
3deba72797
commit
e04b2cf28e
2 files changed
+35
-1
No files matched your search
@@ -1,8 +1,11 @@
|
||||
package durable
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
"testing/synctest"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -24,3 +27,34 @@ func TestMaintenanceVolumePhasesDoNotAlign(t *testing.T) {
|
||||
t.Fatalf("200 volumes collapsed into %d phases", len(seen))
|
||||
}
|
||||
}
|
||||
|
||||
// Virtual quiescence observes the join boundary directly, so a slow storage
|
||||
// Close cannot accidentally make an omitted scheduler join look correct.
|
||||
func TestMaintenanceStopJoinsBeforeRelease(t *testing.T) {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
done, release, cancelled := make(chan struct{}), make(chan struct{}), make(chan struct{})
|
||||
var once sync.Once
|
||||
finish := func() { once.Do(func() { close(release) }) }
|
||||
defer finish()
|
||||
p := &DurableProvider{}
|
||||
h := &volHandle{chunkStop: cancel, chunkDone: done}
|
||||
go func() { <-ctx.Done(); close(cancelled); <-release; close(done) }()
|
||||
returned1, returned2 := make(chan struct{}), make(chan struct{})
|
||||
go func() { p.stopChunkLoop(h); close(returned1) }()
|
||||
<-cancelled
|
||||
go func() { p.stopChunkLoop(h); close(returned2) }()
|
||||
synctest.Wait()
|
||||
for _, returned := range []chan struct{}{returned1, returned2} {
|
||||
select {
|
||||
case <-returned:
|
||||
t.Error("stop released before worker join")
|
||||
default:
|
||||
}
|
||||
}
|
||||
finish()
|
||||
<-returned1
|
||||
<-returned2
|
||||
})
|
||||
}
|
||||
@@ -525,7 +525,7 @@ Notes:
|
||||
| `INV-CHUNK-WRITE-ONCE-001` | Chunk and segment keys are write-once: a key that exists or once existed is refused, and a volume writes only its own keys. | M6 key: Bound | `core/frontend/chunkstore/chunk_remote.go` `putObject` | `TestChunkRemote_KeysAreWriteOnce` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C5_ChunksAreImmutable` (`core/storage/chunk_layer_contract_test.go`) | — | ACTIVE |
|
||||
| `INV-MAINT-ONE-OWNER` | One attached volume admits at most one maintenance pass; elapsed ticks coalesce and never enqueue catch-up work. | M8 Armed → Running | `provider_chunk.go` `chunkMaintenanceLoop` | `TestMaintenanceCoalescesWhileOnePassIsHeld`, `TestMaintenancePassHasOneDeadline` | `MaintenanceOwner` `OneOwner` | ACTIVE |
|
||||
| `INV-MAINT-SCOPE` | Per-volume GC traces foreign roots while restricting candidate reclamation, intent expiry and copy settlement to its volume; namespace coverage is not imported. | M8 scoped GC | `gc.go` `Collector.run`; `gc_copy.go` `SweepCopies`; `gc_execution.go` `ExecuteVolumeGC` | `TestVolumeGC_ForeignIntentRootsAndLocalCandidates`, `TestVolumeGC_DoesNotImportGlobalMark` | `ScopedMaintenanceGC` `ForeignRootSurvives`, `ForeignCandidatesUntouched`, `OwnCoverageOnly` | ACTIVE |
|
||||
| `INV-MAINT-JOIN` | Detach/fence/Close cancels maintenance and joins admitted workers before releasing its catalog/storage lifetime. | M8 Running → Draining → Closed | `provider_chunk.go` `chunkBackground`, `stopChunkLoop` | `TestMaintenanceCloseCancelsAndJoinsWithoutGuestLock`, `TestMaintenanceAuthorityLossCancelsHeldPass` | `MaintenanceOwner` `JoinedBeforeRelease` | ACTIVE |
|
||||
| `INV-MAINT-JOIN` | Detach/fence/Close cancels maintenance and joins admitted workers before releasing its catalog/storage lifetime. | M8 Running → Draining → Closed | `provider_chunk.go` `chunkBackground`, `stopChunkLoop` | `TestMaintenanceStopJoinsBeforeRelease`, `TestMaintenanceCloseCancelsAndJoinsWithoutGuestLock`, `TestMaintenanceAuthorityLossCancelsHeldPass` | `MaintenanceOwner` `JoinedBeforeRelease` | ACTIVE |
|
||||
| `INV-GC-REACHABLE-001` | GC never deletes a chunk reachable from a HEAD, a snapshot, an attempt or a live intent, and deletes a binding only after two marks at least one grace period apart. | M6 key: Bound → Tombstoned | `core/frontend/chunkstore/gc.go` `Collector.run` | `TestGC_UnreachableRequiresTwoMarksAndUploadAge`, `TestGC_StalledCutRemainsReadableAfterTwoMarks`, `TestGC_SnapshotAndQualifiedForkAreRoots` (`core/frontend/chunkstore/gc_test.go`) | `ChunkLifecycleFixed` `GCSafe`; `RetentionGCTiming` `NoLiveDelete` | ACTIVE |
|
||||
| `INV-GC-INTENT-EXPIRY-001` | A capture intent expires only when it is older than the TTL, blockmaster has issued a higher epoch, and remote HEAD has moved to a higher epoch. | M6 intent: Live → Expired | `core/frontend/chunkstore/gc.go` `Collector.run` | `TestGC_IntentExpiryNeedsTTLAuthorityAndRemoteFence` (`core/frontend/chunkstore/gc_test.go`) | `WorkspaceTakeover` `NoLiveIntentExpired`, `GCSafe` | ACTIVE |
|
||||
| `INV-GC-UNREADABLE-SEGMENT-001` | An unreadable published segment aborts the whole GC pass before any deletion. | M6 GC mark | `core/frontend/chunkstore/gc.go` `Collector.run` | `TestManifest_UnreadablePublishedSegmentRefusesWholeGC` (`core/frontend/chunkstore/manifest_test.go`) | — | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user