From ae372a6faeb8b90392d52173dfe77ee26f8eb344 Mon Sep 17 00:00:00 2001 From: iamlinjunhong <1030420200@qq.com> Date: Tue, 13 May 2025 14:38:10 +0800 Subject: [PATCH] fix concurrent map read and map write --- pkg/lockservice/lock_table_allocator.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/lockservice/lock_table_allocator.go b/pkg/lockservice/lock_table_allocator.go index 0131b65c4cdb3..cec85882139dd 100644 --- a/pkg/lockservice/lock_table_allocator.go +++ b/pkg/lockservice/lock_table_allocator.go @@ -154,8 +154,8 @@ func (l *lockTableAllocator) Valid( binds []pb.LockTable, ) ([]uint64, error) { var invalid []uint64 - l.mu.RLock() - defer l.mu.RUnlock() + l.mu.Lock() + defer l.mu.Unlock() for _, b := range binds { if !b.Valid { @@ -210,8 +210,8 @@ func (l *lockTableAllocator) Close() error { } func (l *lockTableAllocator) GetLatest(groupID uint32, tableID uint64) pb.LockTable { - l.mu.RLock() - defer l.mu.RUnlock() + l.mu.Lock() + defer l.mu.Unlock() m := l.getLockTablesLocked(groupID) if old, ok := m[tableID]; ok {