Skip to content

Commit 3d72685

Browse files
fix concurrent map read and map write (#21833)
fix concurrent map read and map write Approved by: @XuPeng-SH, @zhangxu19830126
1 parent dbaf3df commit 3d72685

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/lockservice/lock_table_allocator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ func (l *lockTableAllocator) Valid(
154154
binds []pb.LockTable,
155155
) ([]uint64, error) {
156156
var invalid []uint64
157-
l.mu.RLock()
158-
defer l.mu.RUnlock()
157+
l.mu.Lock()
158+
defer l.mu.Unlock()
159159

160160
for _, b := range binds {
161161
if !b.Valid {
@@ -210,8 +210,8 @@ func (l *lockTableAllocator) Close() error {
210210
}
211211

212212
func (l *lockTableAllocator) GetLatest(groupID uint32, tableID uint64) pb.LockTable {
213-
l.mu.RLock()
214-
defer l.mu.RUnlock()
213+
l.mu.Lock()
214+
defer l.mu.Unlock()
215215

216216
m := l.getLockTablesLocked(groupID)
217217
if old, ok := m[tableID]; ok {

0 commit comments

Comments
 (0)