From de2fca826b371d5b5cd6e1bbb8411d8b09fe2963 Mon Sep 17 00:00:00 2001 From: sdojjy Date: Wed, 3 Nov 2021 10:40:17 +0800 Subject: [PATCH] schema storage shallow copy DBInfo (#3085) * schema storage shallow copy DBInfo Signed-off-by: sdojjy * schema storage shallow copy DBInfo --- cdc/entry/schema_storage.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cdc/entry/schema_storage.go b/cdc/entry/schema_storage.go index 7a81f6315ec..a18bd559298 100644 --- a/cdc/entry/schema_storage.go +++ b/cdc/entry/schema_storage.go @@ -226,7 +226,8 @@ func (s *schemaSnapshot) Clone() *schemaSnapshot { schemas := make(map[int64]*timodel.DBInfo, len(s.schemas)) for k, v := range s.schemas { - schemas[k] = v.Clone() + // DBInfo is readonly in TiCDC, shallow copy to reduce memory + schemas[k] = v.Copy() } clone.schemas = schemas @@ -389,7 +390,7 @@ func (s *schemaSnapshot) createSchema(db *timodel.DBInfo) error { return cerror.ErrSnapshotSchemaExists.GenWithStackByArgs(db.Name, db.ID) } - s.schemas[db.ID] = db.Clone() + s.schemas[db.ID] = db.Copy() s.schemaNameToID[db.Name.O] = db.ID s.tableInSchema[db.ID] = []int64{} @@ -402,7 +403,7 @@ func (s *schemaSnapshot) replaceSchema(db *timodel.DBInfo) error { if !ok { return cerror.ErrSnapshotSchemaNotFound.GenWithStack("schema %s(%d) not found", db.Name, db.ID) } - s.schemas[db.ID] = db.Clone() + s.schemas[db.ID] = db.Copy() s.schemaNameToID[db.Name.O] = db.ID return nil }