-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v2.x-input-mysql-replicate-db-may-error-by-restart-bug'…
… into v2.2.3 * v2.x-input-mysql-replicate-db-may-error-by-restart-bug: 修复MySQL源,指定同步表配置后,但可能没生效的BUG BUG复现过程: 1. 配置了一个T1表同步 2. 重启进程,并且T1表数据不再做任何更新 3. 配置T2表同步 4. 更新T1表的数据
- Loading branch information
Showing
2 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,62 @@ | ||
package mysql | ||
|
||
func (c *MysqlInput) AddReplicateDoDb(SchemaName,TableName string) (err error) { | ||
func (c *MysqlInput) AddReplicateDoDb(SchemaName, TableName string) (err error) { | ||
c.AddReplicateDoDb0(SchemaName, TableName) | ||
if c.binlogDump == nil { | ||
return | ||
} | ||
c.binlogDump.AddReplicateDoDb(SchemaName,TableName) | ||
c.binlogDump.AddReplicateDoDb(SchemaName, TableName) | ||
return nil | ||
} | ||
|
||
func (c *MysqlInput) DelReplicateDoDb(SchemaName,TableName string) (err error) { | ||
func (c *MysqlInput) AddReplicateDoDb0(SchemaName, TableName string) { | ||
c.Lock() | ||
defer c.Unlock() | ||
if c.replicateDoDb == nil { | ||
c.replicateDoDb = make(map[string]map[string]bool, 0) | ||
} | ||
if _, ok := c.replicateDoDb[SchemaName]; !ok { | ||
c.replicateDoDb[SchemaName] = make(map[string]bool, 0) | ||
} | ||
c.replicateDoDb[SchemaName][TableName] = true | ||
return | ||
} | ||
|
||
func (c *MysqlInput) DelReplicateDoDb(SchemaName, TableName string) (err error) { | ||
c.DelReplicateDoDb0(SchemaName, TableName) | ||
if c.binlogDump == nil { | ||
return | ||
} | ||
c.binlogDump.DelReplicateDoDb(SchemaName,TableName) | ||
c.binlogDump.DelReplicateDoDb(SchemaName, TableName) | ||
return nil | ||
} | ||
} | ||
|
||
func (c *MysqlInput) DelReplicateDoDb0(SchemaName, TableName string) { | ||
c.Lock() | ||
defer c.Unlock() | ||
if c.replicateDoDb == nil { | ||
return | ||
} | ||
if _, ok := c.replicateDoDb[SchemaName]; !ok { | ||
return | ||
} | ||
delete(c.replicateDoDb[SchemaName], TableName) | ||
return | ||
} | ||
|
||
func (c *MysqlInput) InitBinlogDumpReplicateDoDb() { | ||
c.Lock() | ||
defer c.Unlock() | ||
if c.replicateDoDb == nil { | ||
return | ||
} | ||
if c.binlogDump == nil { | ||
return | ||
} | ||
for schemaName, replicateDoDbTablesMap := range c.replicateDoDb { | ||
for tableName := range replicateDoDbTablesMap { | ||
c.binlogDump.AddReplicateDoDb(schemaName, tableName) | ||
} | ||
} | ||
return | ||
} |