mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
storage: #959 gate test joins both workers before the store closes
The cleanup keeps both worker handles in scope: it ends the admitted write and releases the hold, then joins the hold worker and, if started, the held extent-write worker, each bounded with a reported timeout, and closes stop only after the joins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
419f2b65b5
commit
260aeffda1
1 file changed
+16
-2
@@ -350,17 +350,31 @@ func TestAHoldWaitsForAnAdmittedExtentWriteAndHoldsNewOnes(t *testing.T) {
|
||||
held := make(chan func(), 1)
|
||||
go func() { held <- s.holdExtentWrites() }()
|
||||
var release func()
|
||||
t.Cleanup(func() { // every exit: the admitted write ends, the hold is released, waiters stop
|
||||
next := make(chan struct{}) // the second worker's end; nil until it starts
|
||||
var nextStarted bool
|
||||
// Every exit, before the store's own cleanup: the admitted write ends and
|
||||
// the hold is released, then each started worker is joined (bounded, a
|
||||
// timeout reported). Releasing the hold lets the second worker finish;
|
||||
// stop is closed only after the joins.
|
||||
t.Cleanup(func() {
|
||||
finish()
|
||||
if release == nil {
|
||||
select {
|
||||
case release = <-held:
|
||||
case <-time.After(ctLocalBound):
|
||||
t.Error("cleanup: the hold worker did not return")
|
||||
}
|
||||
}
|
||||
if release != nil {
|
||||
release()
|
||||
}
|
||||
if nextStarted {
|
||||
select {
|
||||
case <-next:
|
||||
case <-time.After(ctLocalBound):
|
||||
t.Error("cleanup: the held extent-write worker did not finish")
|
||||
}
|
||||
}
|
||||
close(stop)
|
||||
})
|
||||
for deadline := time.Now().Add(ctLocalBound); ; time.Sleep(100 * time.Microsecond) {
|
||||
@@ -384,7 +398,7 @@ func TestAHoldWaitsForAnAdmittedExtentWriteAndHoldsNewOnes(t *testing.T) {
|
||||
t.Fatal("the hold did not return after the admitted write finished")
|
||||
}
|
||||
waits := s.extentHeldWaits.Load()
|
||||
next := make(chan struct{})
|
||||
nextStarted = true
|
||||
go func() { s.admitExtentWrite(stop)(); close(next) }()
|
||||
for deadline := time.Now().Add(ctLocalBound); s.extentHeldWaits.Load() == waits; time.Sleep(100 * time.Microsecond) {
|
||||
select {
|
||||
|
||||
Reference in new issue
Block a user