-
Notifications
You must be signed in to change notification settings - Fork 712
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
client: fix Stream timeout logic #5551
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a2ed03b
fix
CabinfeverB cfc21ee
fix
CabinfeverB 5357ad9
add test
CabinfeverB 7ab2a0e
add test
CabinfeverB d58f9f3
fix
CabinfeverB 321c3aa
address comment
CabinfeverB 1e9e9b8
Merge branch 'master' into client_tso_retry
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,6 +347,69 @@ func TestTSOFollowerProxy(t *testing.T) { | |
wg.Wait() | ||
} | ||
|
||
// TestUnavailableTimeAfterLeaderIsReady is used to test https://github.com/tikv/pd/issues/5207 | ||
func TestUnavailableTimeAfterLeaderIsReady(t *testing.T) { | ||
re := require.New(t) | ||
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. How long does this test take to run? 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. I will paste a test result |
||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
cluster, err := tests.NewTestCluster(ctx, 3) | ||
re.NoError(err) | ||
defer cluster.Destroy() | ||
|
||
endpoints := runServer(re, cluster) | ||
cli := setupCli(re, ctx, endpoints) | ||
|
||
var wg sync.WaitGroup | ||
var maxUnavailableTime, leaderReadyTime time.Time | ||
getTsoFunc := func() { | ||
defer wg.Done() | ||
var lastTS uint64 | ||
for i := 0; i < tsoRequestRound; i++ { | ||
var physical, logical int64 | ||
var ts uint64 | ||
physical, logical, err = cli.GetTS(context.Background()) | ||
ts = tsoutil.ComposeTS(physical, logical) | ||
if err != nil { | ||
maxUnavailableTime = time.Now() | ||
continue | ||
} | ||
re.NoError(err) | ||
re.Less(lastTS, ts) | ||
lastTS = ts | ||
} | ||
} | ||
|
||
// test resign pd leader or stop pd leader | ||
wg.Add(1 + 1) | ||
go getTsoFunc() | ||
go func() { | ||
defer wg.Done() | ||
leader := cluster.GetServer(cluster.GetLeader()) | ||
leader.Stop() | ||
cluster.WaitLeader() | ||
leaderReadyTime = time.Now() | ||
cluster.RunServers([]*tests.TestServer{leader}) | ||
}() | ||
wg.Wait() | ||
re.Less(maxUnavailableTime.UnixMilli(), leaderReadyTime.Add(1*time.Second).UnixMilli()) | ||
|
||
// test kill pd leader pod or network of leader is unreachable | ||
wg.Add(1 + 1) | ||
maxUnavailableTime, leaderReadyTime = time.Time{}, time.Time{} | ||
go getTsoFunc() | ||
go func() { | ||
defer wg.Done() | ||
leader := cluster.GetServer(cluster.GetLeader()) | ||
re.NoError(failpoint.Enable("github.com/tikv/pd/client/unreachableNetwork", "return(true)")) | ||
leader.Stop() | ||
cluster.WaitLeader() | ||
re.NoError(failpoint.Disable("github.com/tikv/pd/client/unreachableNetwork")) | ||
leaderReadyTime = time.Now() | ||
}() | ||
wg.Wait() | ||
re.Less(maxUnavailableTime.UnixMilli(), leaderReadyTime.Add(1*time.Second).UnixMilli()) | ||
} | ||
|
||
func TestGlobalAndLocalTSO(t *testing.T) { | ||
re := require.New(t) | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
|
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.
Will the new implementation timeout immediately when back to streamChoosingLoop?
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.
No, it will check whether stream is created. If created, it will not timeout