Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
jiawen li
tidb
Commits
aaa42620
Unverified
Commit
aaa42620
authored
4 years ago
by
Zhou Kunqin
Committed by
GitHub
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
store: fix possible index out of range in (*RegionStore).kvPeer() (#22319)
parent
c2c767a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
store/tikv/region_cache.go
+1
-1
store/tikv/region_cache.go
store/tikv/region_cache_test.go
+1
-0
store/tikv/region_cache_test.go
with
2 additions
and
1 deletion
+2
-1
store/tikv/region_cache.go
+
1
-
1
View file @
aaa42620
...
...
@@ -174,7 +174,7 @@ func (r *RegionStore) kvPeer(seed uint32) AccessIndex {
if
len
(
candidates
)
==
0
{
return
r
.
workTiKVIdx
}
return
candidates
[
int32
(
seed
)
%
int32
(
len
(
candidates
))]
return
candidates
[
seed
%
u
int32
(
len
(
candidates
))]
}
// init initializes region after constructed.
...
...
This diff is collapsed.
Click to expand it.
store/tikv/region_cache_test.go
+
1
-
0
View file @
aaa42620
...
...
@@ -128,6 +128,7 @@ func (s *testRegionCacheSuite) TestSimple(c *C) {
c
.
Assert
(
r
.
GetID
(),
Equals
,
s
.
region1
)
c
.
Assert
(
s
.
getAddr
(
c
,
[]
byte
(
"a"
),
kv
.
ReplicaReadLeader
,
0
),
Equals
,
s
.
storeAddr
(
s
.
store1
))
c
.
Assert
(
s
.
getAddr
(
c
,
[]
byte
(
"a"
),
kv
.
ReplicaReadFollower
,
seed
),
Equals
,
s
.
storeAddr
(
s
.
store2
))
c
.
Assert
(
s
.
getAddr
(
c
,
[]
byte
(
"a"
),
kv
.
ReplicaReadMixed
,
1
<<
31
+
1
),
Equals
,
s
.
storeAddr
(
s
.
store2
))
s
.
checkCache
(
c
,
1
)
c
.
Assert
(
r
.
GetMeta
(),
DeepEquals
,
r
.
meta
)
c
.
Assert
(
r
.
GetLeaderPeerID
(),
Equals
,
r
.
meta
.
Peers
[
r
.
getStore
()
.
workTiKVIdx
]
.
Id
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help