diff --git a/go/mysql/auth_server_static_test.go b/go/mysql/auth_server_static_test.go index 2586da2f60b..f195b4c72d1 100644 --- a/go/mysql/auth_server_static_test.go +++ b/go/mysql/auth_server_static_test.go @@ -207,10 +207,6 @@ func hupTestWithRotation(t *testing.T, aStatic *AuthServerStatic, tmpFile *os.Fi t.Fatalf("couldn't overwrite temp file: %v", err) } - if aStatic.getEntries()[oldStr][0].Password != oldStr { - t.Fatalf("%s's Password should still be '%s'", oldStr, oldStr) - } - time.Sleep(20 * time.Millisecond) // wait for signal handler if aStatic.getEntries()[oldStr] != nil { diff --git a/go/test/endtoend/messaging/message_test.go b/go/test/endtoend/messaging/message_test.go index e5ada917cbf..b93b9c7c5e2 100644 --- a/go/test/endtoend/messaging/message_test.go +++ b/go/test/endtoend/messaging/message_test.go @@ -331,6 +331,7 @@ func TestConnection(t *testing.T) { _, err = stream.MessageStream(userKeyspace, "", nil, name) require.Nil(t, err) // validate client count of vttablet + time.Sleep(time.Second) assert.Equal(t, 1, getClientCount(shard0Master)) assert.Equal(t, 1, getClientCount(shard1Master)) // second connection with vtgate, secont connection @@ -340,6 +341,7 @@ func TestConnection(t *testing.T) { _, err = stream1.MessageStream(userKeyspace, "", nil, name) require.Nil(t, err) // validate client count of vttablet + time.Sleep(time.Second) assert.Equal(t, 2, getClientCount(shard0Master)) assert.Equal(t, 2, getClientCount(shard1Master)) diff --git a/go/vt/key/destination.go b/go/vt/key/destination.go index 66946504978..235f561c2d7 100644 --- a/go/vt/key/destination.go +++ b/go/vt/key/destination.go @@ -20,6 +20,7 @@ import ( "bytes" "encoding/hex" "math/rand" + "sort" "strings" "vitess.io/vitess/go/vt/vterrors" @@ -149,6 +150,10 @@ func (d DestinationExactKeyRange) String() string { } func processExactKeyRange(allShards []*topodatapb.ShardReference, kr *topodatapb.KeyRange, addShard func(shard string) error) error { + sort.SliceStable(allShards, func(i, j int) bool { + return KeyRangeStartSmaller(allShards[i].GetKeyRange(), allShards[j].GetKeyRange()) + }) + shardnum := 0 for shardnum < len(allShards) { if KeyRangeStartEqual(kr, allShards[shardnum].KeyRange) { diff --git a/go/vt/key/key.go b/go/vt/key/key.go index 0bd7f137a34..98143a1ff13 100644 --- a/go/vt/key/key.go +++ b/go/vt/key/key.go @@ -185,6 +185,17 @@ func KeyRangeEqual(left, right *topodatapb.KeyRange) bool { bytes.Equal(left.End, right.End) } +// KeyRangeStartEqual returns true if right's keyrange start is _after_ left's start +func KeyRangeStartSmaller(left, right *topodatapb.KeyRange) bool { + if left == nil { + return right != nil + } + if right == nil { + return false + } + return bytes.Compare(left.Start, right.Start) < 0 +} + // KeyRangeStartEqual returns true if both key ranges have the same start func KeyRangeStartEqual(left, right *topodatapb.KeyRange) bool { if left == nil {