Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions canal/canal.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (c *Canal) prepareDumper() error {
c.dumper.SetCharset(charset)

c.dumper.SkipMasterData(c.cfg.Dump.SkipMasterData)
c.dumper.SetMaxAllowedPacket(c.cfg.Dump.MaxAllowedPacketMB)

for _, ignoreTable := range c.cfg.Dump.IgnoreTables {
if seps := strings.Split(ignoreTable, ","); len(seps) == 2 {
Expand Down
3 changes: 3 additions & 0 deletions canal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type DumpConfig struct {
// Set true to skip --master-data if we have no privilege to do
// 'FLUSH TABLES WITH READ LOCK'
SkipMasterData bool `toml:"skip_master_data"`

// Set to change the default max_allowed_packet size
MaxAllowedPacketMB int `toml:"max_allowed_packet_mb"`
}

type Config struct {
Expand Down
9 changes: 9 additions & 0 deletions dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Dumper struct {
ErrOut io.Writer

masterDataSkipped bool
maxAllowedPacket int
}

func NewDumper(executionPath string, addr string, user string, password string) (*Dumper, error) {
Expand Down Expand Up @@ -74,6 +75,10 @@ func (d *Dumper) SkipMasterData(v bool) {
d.masterDataSkipped = v
}

func (d *Dumper) SetMaxAllowedPacket(i int) {
d.maxAllowedPacket = i
}

func (d *Dumper) AddDatabases(dbs ...string) {
d.Databases = append(d.Databases, dbs...)
}
Expand Down Expand Up @@ -117,6 +122,10 @@ func (d *Dumper) Dump(w io.Writer) error {
args = append(args, "--master-data")
}

if d.maxAllowedPacket > 0 {
args = append(args, fmt.Sprintf("--max_allowed_packet=%dM", d.maxAllowedPacket))
}

args = append(args, "--single-transaction")
args = append(args, "--skip-lock-tables")

Expand Down