Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions go/mysql/auth_server_static_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions go/test/endtoend/messaging/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))

Expand Down
5 changes: 5 additions & 0 deletions go/vt/key/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"encoding/hex"
"math/rand"
"sort"
"strings"

"vitess.io/vitess/go/vt/vterrors"
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions go/vt/key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down