mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
test: hold ambiguous outcome lookup during permanent attach outage
This commit is contained in:
1 parent
257c50e2f2
commit
ad494f7200
2 files changed
+18
-1
No files matched your search
@@ -63,7 +63,7 @@ func TestHeadBeltProviderCloseCancelsCooling(t *testing.T) {
|
||||
go func() { _, err := p.RecoverVolume(ctx, "v1"); recovered <- err }()
|
||||
select {
|
||||
case <-r.claimed:
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("takeover did not reach cooling")
|
||||
}
|
||||
closeStarted = true
|
||||
|
||||
@@ -26,6 +26,23 @@ type heldTakeoverClaim struct {
|
||||
}
|
||||
|
||||
func (r *heldTakeoverClaim) unblock() { r.releaseOnce.Do(func() { close(r.release) }) }
|
||||
func (r *heldTakeoverClaim) GetHead(ctx context.Context) (storage.ChunkHead, error) {
|
||||
// The permanent-outage case must hold outcome resolution as well as the
|
||||
// CAS reply: a committed CAS with readable HEAD can now settle after the
|
||||
// per-operation deadline. Unbounded diagnostic reads still see the root.
|
||||
if _, bounded := ctx.Deadline(); bounded && r.holdFor == 0 {
|
||||
select {
|
||||
case <-r.claimed:
|
||||
select {
|
||||
case <-r.release:
|
||||
case <-ctx.Done():
|
||||
return storage.ChunkHead{}, ctx.Err()
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
return r.ChunkRemote.GetHead(ctx)
|
||||
}
|
||||
func (r *heldTakeoverClaim) CASHead(ctx context.Context, expected storage.ChunkHeadVersion, next storage.ChunkHead) (uint64, error) {
|
||||
gen, err := r.ChunkRemote.CASHead(ctx, expected, next)
|
||||
if err != nil || next.Epoch != 4 {
|
||||
|
||||
Reference in new issue
Block a user