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))