Skip to content

Commit

Permalink
schema storage shallow copy DBInfo (#3085)
Browse files Browse the repository at this point in the history
* schema storage shallow copy DBInfo

Signed-off-by: sdojjy <[email protected]>

* schema storage shallow copy DBInfo
  • Loading branch information
sdojjy authored Nov 3, 2021
1 parent 9157bb4 commit de2fca8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cdc/entry/schema_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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{}

Expand All @@ -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
}
Expand Down

0 comments on commit de2fca8

Please sign in to comment.