Skip to content

Commit 60636c2

Browse files
committed
change config name and add to canal
1 parent 23711c9 commit 60636c2

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

canal/canal.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ func (c *Canal) prepareSyncer() error {
466466
Dialer: c.cfg.Dialer,
467467
Localhost: c.cfg.Localhost,
468468
EventCacheCount: c.cfg.EventCacheCount,
469+
FillZeroLogPos: c.cfg.FillZeroLogPos,
470+
469471
RowsEventDecodeFunc: func(event *replication.RowsEvent, data []byte) error {
470472
pos, err := event.DecodeHeader(data)
471473
if err != nil {

canal/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ type Config struct {
113113
// the default value is 10240.
114114
// if you table contain large columns, you can decrease this value to avoid OOM.
115115
EventCacheCount int
116+
117+
// FillZeroLogPos enables dynamic LogPos calculation for MariaDB.
118+
// When enabled, automatically adds BINLOG_SEND_ANNOTATE_ROWS_EVENT flag
119+
// to ensure correct position calculation in MariaDB 11.4+.
120+
// Only works with MariaDB flavor.
121+
FillZeroLogPos bool
116122
}
117123

118124
func NewConfigWithFile(name string) (*Config, error) {

replication/binlogsyncer.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ type BinlogSyncerConfig struct {
128128

129129
EventCacheCount int
130130

131-
// MariaDBDynamicLogPos enables dynamic LogPos calculation for MariaDB.
131+
// FillZeroLogPos enables dynamic LogPos calculation for MariaDB.
132132
// When enabled, automatically adds BINLOG_SEND_ANNOTATE_ROWS_EVENT flag
133133
// to ensure correct position calculation in MariaDB 11.4+.
134134
// Only works with MariaDB flavor.
135-
MariaDBDynamicLogPos bool
135+
FillZeroLogPos bool
136136

137137
// SynchronousEventHandler is used for synchronous event handling.
138138
// This should not be used together with StartBackupWithHandler.
@@ -516,8 +516,8 @@ func (b *BinlogSyncer) writeBinlogDumpCommand(p mysql.Position) error {
516516
pos += 4
517517

518518
dumpCommandFlag := b.cfg.DumpCommandFlag
519-
if b.cfg.MariaDBDynamicLogPos && b.cfg.Flavor == mysql.MariaDBFlavor {
520-
// Add BINLOG_SEND_ANNOTATE_ROWS_EVENT flag when MariaDBDynamicLogPos is enabled.
519+
if b.cfg.FillZeroLogPos && b.cfg.Flavor == mysql.MariaDBFlavor {
520+
// Add BINLOG_SEND_ANNOTATE_ROWS_EVENT flag when FillZeroLogPos is enabled.
521521
// This ensures the server sends ANNOTATE_ROWS_EVENT events which are needed
522522
// for correct LogPos calculation in MariaDB 11.4+, where some events have LogPos=0.
523523
dumpCommandFlag |= BINLOG_SEND_ANNOTATE_ROWS_EVENT
@@ -966,12 +966,12 @@ func (b *BinlogSyncer) handleEventAndACK(s *BinlogStreamer, e *BinlogEvent, need
966966

967967
// shouldCalculateDynamicLogPos determines if we should calculate LogPos dynamically for MariaDB events.
968968
// This is needed for MariaDB 11.4+ when:
969-
// 1. MariaDBDynamicLogPos is enabled
969+
// 1. FillZeroLogPos is enabled
970970
// 2. We're using MariaDB flavor
971971
// 3. The event has LogPos=0 (indicating server didn't set it)
972972
// 4. The event is not artificial (not marked with LOG_EVENT_ARTIFICIAL_F flag)
973973
func (b *BinlogSyncer) shouldCalculateDynamicLogPos(e *BinlogEvent) bool {
974-
return b.cfg.MariaDBDynamicLogPos &&
974+
return b.cfg.FillZeroLogPos &&
975975
b.cfg.Flavor == mysql.MariaDBFlavor &&
976976
e.Header.LogPos == 0 &&
977977
(e.Header.Flags&LOG_EVENT_ARTIFICIAL_F) == 0

0 commit comments

Comments
 (0)