You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-8Lines changed: 34 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ import (
62
62
"github.com/go-mysql-org/go-mysql/replication"
63
63
"os"
64
64
)
65
-
// Create a binlog syncer with a unique server id, the server id must be different from other MySQL's.
65
+
// Create a binlog syncer with a unique server id, the server id must be different from other MySQL's.
66
66
// flavor is mysql or mariadb
67
67
cfg:= replication.BinlogSyncerConfig {
68
68
ServerID: 100,
@@ -133,13 +133,39 @@ Schema: test
133
133
Query: DROP TABLE IF EXISTS `test_replication` /* generated by server */
134
134
```
135
135
136
-
## Canal
136
+
### MariaDB 11.4+ compatibility
137
+
138
+
MariaDB 11.4+ introduced an optimization where events written through transaction or statement cache have `LogPos=0` so they can be copied directly to the binlog without computing the real end position. This optimization improves performance but makes position tracking unreliable for replication clients that need to track LogPos of events inside transactions.
139
+
140
+
To address this, a `FillZeroLogPos` configuration option is available:
141
+
142
+
```go
143
+
cfg:= replication.BinlogSyncerConfig {
144
+
ServerID: 100,
145
+
Flavor: "mariadb",
146
+
Host: "127.0.0.1",
147
+
Port: 3306,
148
+
User: "root",
149
+
Password: "",
150
+
// Enable dynamic LogPos calculation for MariaDB 11.4+
151
+
FillZeroLogPos: true,
152
+
}
153
+
```
154
+
155
+
**Behavior:**
156
+
- When `FillZeroLogPos` is `true` and flavor is `mariadb`, the library automatically:
157
+
- Adds `BINLOG_SEND_ANNOTATE_ROWS_EVENT` flag to binlog dump commands. This ensures correct position tracking by making the server send `ANNOTATE_ROWS_EVENT` events which are needed for accurate position calculation.
158
+
- Calculates LogPos dynamically for events with `LogPos=0` that are not artificial.
159
+
- Only works with MariaDB flavor; has no effect with MySQL.
160
+
- Should be set to `true` if tracking of LogPos inside transactions is required.
161
+
162
+
## Canal
137
163
138
164
Canal is a package that can sync your MySQL into everywhere, like Redis, Elasticsearch.
139
165
140
-
First, canal will dump your MySQL data then sync changed data using binlog incrementally.
166
+
First, canal will dump your MySQL data then sync changed data using binlog incrementally.
141
167
142
-
You must use ROW format for binlog, full binlog row image is preferred, because we may meet some errors when primary key changed in update for minimal or noblob row image.
168
+
You must use ROW format for binlog, full binlog row image is preferred, because we may meet some errors when primary key changed in update for minimal or noblob row image.
143
169
144
170
A simple example:
145
171
@@ -188,9 +214,9 @@ You can see [go-mysql-elasticsearch](https://github.com/go-mysql-org/go-mysql-el
188
214
189
215
## Client
190
216
191
-
Client package supports a simple MySQL connection driver which you can use it to communicate with MySQL server.
217
+
Client package supports a simple MySQL connection driver which you can use it to communicate with MySQL server.
192
218
193
-
For an example see [`example_client_test.go`](client/example_client_test.go). You can run this testable example with
219
+
For an example see [`example_client_test.go`](client/example_client_test.go). You can run this testable example with
0 commit comments