From bd1f4fbfc095fa8354def8adc50fcdd9900545c1 Mon Sep 17 00:00:00 2001 From: 3pointer Date: Mon, 11 Nov 2024 21:28:19 +0800 Subject: [PATCH 1/3] This is an automated cherry-pick of #57299 Signed-off-by: ti-chi-bot --- br/pkg/streamhelper/basic_lib_for_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/br/pkg/streamhelper/basic_lib_for_test.go b/br/pkg/streamhelper/basic_lib_for_test.go index 2324e27a12b5a..e0956a92c9eee 100644 --- a/br/pkg/streamhelper/basic_lib_for_test.go +++ b/br/pkg/streamhelper/basic_lib_for_test.go @@ -766,6 +766,14 @@ func (t *testEnv) putTask() { } func (t *testEnv) ScanLocksInOneRegion(bo *tikv.Backoffer, key []byte, maxVersion uint64, limit uint32) ([]*txnlock.Lock, *tikv.KeyLocation, error) { +<<<<<<< HEAD +======= + t.mu.Lock() + defer t.mu.Unlock() + if t.maxTs != maxVersion { + return nil, nil, errors.Errorf("unexpect max version in scan lock, expected %d, actual %d", t.maxTs, maxVersion) + } +>>>>>>> 6528da5f400 (test: fix data race in scan locks (#57299)) for _, r := range t.regions { if len(r.locks) != 0 { return r.locks, &tikv.KeyLocation{ @@ -777,6 +785,8 @@ func (t *testEnv) ScanLocksInOneRegion(bo *tikv.Backoffer, key []byte, maxVersio } func (t *testEnv) ResolveLocksInOneRegion(bo *tikv.Backoffer, locks []*txnlock.Lock, loc *tikv.KeyLocation) (*tikv.KeyLocation, error) { + t.mu.Lock() + defer t.mu.Unlock() for _, r := range t.regions { if loc != nil && loc.Region.GetID() == r.id { // reset locks From 46d208589c09e3d1e95fafeff805d55ba2255912 Mon Sep 17 00:00:00 2001 From: BornChanger <97348524+BornChanger@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:33:28 +0800 Subject: [PATCH 2/3] Update basic_lib_for_test.go --- br/pkg/streamhelper/basic_lib_for_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/br/pkg/streamhelper/basic_lib_for_test.go b/br/pkg/streamhelper/basic_lib_for_test.go index e0956a92c9eee..a44edfecbec6f 100644 --- a/br/pkg/streamhelper/basic_lib_for_test.go +++ b/br/pkg/streamhelper/basic_lib_for_test.go @@ -766,14 +766,11 @@ func (t *testEnv) putTask() { } func (t *testEnv) ScanLocksInOneRegion(bo *tikv.Backoffer, key []byte, maxVersion uint64, limit uint32) ([]*txnlock.Lock, *tikv.KeyLocation, error) { -<<<<<<< HEAD -======= t.mu.Lock() defer t.mu.Unlock() if t.maxTs != maxVersion { return nil, nil, errors.Errorf("unexpect max version in scan lock, expected %d, actual %d", t.maxTs, maxVersion) } ->>>>>>> 6528da5f400 (test: fix data race in scan locks (#57299)) for _, r := range t.regions { if len(r.locks) != 0 { return r.locks, &tikv.KeyLocation{ From 0b50401d787d0a59ec060b8aa40f487b3de26ecd Mon Sep 17 00:00:00 2001 From: BornChanger <97348524+BornChanger@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:40:15 +0800 Subject: [PATCH 3/3] Update basic_lib_for_test.go --- br/pkg/streamhelper/basic_lib_for_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/br/pkg/streamhelper/basic_lib_for_test.go b/br/pkg/streamhelper/basic_lib_for_test.go index a44edfecbec6f..520dbef60ad22 100644 --- a/br/pkg/streamhelper/basic_lib_for_test.go +++ b/br/pkg/streamhelper/basic_lib_for_test.go @@ -768,9 +768,6 @@ func (t *testEnv) putTask() { func (t *testEnv) ScanLocksInOneRegion(bo *tikv.Backoffer, key []byte, maxVersion uint64, limit uint32) ([]*txnlock.Lock, *tikv.KeyLocation, error) { t.mu.Lock() defer t.mu.Unlock() - if t.maxTs != maxVersion { - return nil, nil, errors.Errorf("unexpect max version in scan lock, expected %d, actual %d", t.maxTs, maxVersion) - } for _, r := range t.regions { if len(r.locks) != 0 { return r.locks, &tikv.KeyLocation{