-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clientv3: fix lease "freezing" on unhealthy cluster #7023
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,12 @@ package integration | |
import ( | ||
"reflect" | ||
"sort" | ||
"sync" | ||
"testing" | ||
"time" | ||
|
||
"github.com/coreos/etcd/clientv3" | ||
"github.com/coreos/etcd/clientv3/concurrency" | ||
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" | ||
"github.com/coreos/etcd/integration" | ||
"github.com/coreos/etcd/pkg/testutil" | ||
|
@@ -574,3 +576,57 @@ func TestLeaseKeepAliveLoopExit(t *testing.T) { | |
t.Fatalf("expected %T, got %v(%T)", clientv3.ErrKeepAliveHalted{}, err, err) | ||
} | ||
} | ||
|
||
// TestV3LeaseFailureOverlap issues Grant and Keepalive requests to a cluster | ||
// before, during, and after quorum loss to confirm Grant/Keepalive tolerates | ||
// transient cluster failure. | ||
func TestV3LeaseFailureOverlap(t *testing.T) { | ||
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 2}) | ||
defer clus.Terminate(t) | ||
|
||
numReqs := 5 | ||
cli := clus.Client(0) | ||
|
||
// bring up a session, tear it down | ||
updown := func(i int) error { | ||
sess, err := concurrency.NewSession(cli) | ||
if err != nil { | ||
return err | ||
} | ||
ch := make(chan struct{}) | ||
go func() { | ||
defer close(ch) | ||
sess.Close() | ||
}() | ||
select { | ||
case <-ch: | ||
case <-time.After(time.Minute / 4): | ||
t.Fatalf("timeout %d", i) | ||
} | ||
return nil | ||
} | ||
|
||
var wg sync.WaitGroup | ||
mkReqs := func(n int) { | ||
wg.Add(numReqs) | ||
for i := 0; i < numReqs; i++ { | ||
go func() { | ||
defer wg.Done() | ||
err := updown(n) | ||
if err == nil || err == rpctypes.ErrTimeoutDueToConnectionLost { | ||
return | ||
} | ||
t.Fatal(err) | ||
}() | ||
} | ||
} | ||
|
||
mkReqs(1) | ||
clus.Members[1].Stop(t) | ||
mkReqs(2) | ||
time.Sleep(time.Second) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q. Why do we wait here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. otherwise the leader resumes too fast; couldn't trigger the failure without it |
||
mkReqs(3) | ||
clus.Members[1].Restart(t) | ||
mkReqs(4) | ||
wg.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be nice to add some explanation to why we need this test in the file. so the future reader might have a context.
Other than that LGTM.