From d8f0a6ea8b7e40cc37bf08f2d7418ca2df3cc30b Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Tue, 10 Dec 2024 14:12:36 +0800 Subject: [PATCH] snapshot(ticdc): fix the data race when log set to debug caused by print logs (#11830) (#11835) close pingcap/tiflow#11827 --- cdc/entry/schema/snapshot.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cdc/entry/schema/snapshot.go b/cdc/entry/schema/snapshot.go index b188ffcf5a7..0e1971e8c64 100644 --- a/cdc/entry/schema/snapshot.go +++ b/cdc/entry/schema/snapshot.go @@ -570,6 +570,9 @@ func (s *Snapshot) SchemaCount() (count int) { // DumpToString dumps the snapshot to a string. func (s *Snapshot) DumpToString() string { + s.rwlock.RLock() + defer s.rwlock.RUnlock() + schemas := make([]string, 0, s.inner.schemas.Len()) s.IterSchemas(func(dbInfo *timodel.DBInfo) { schemas = append(schemas, fmt.Sprintf("%v", dbInfo))