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
fix(replication): calculate LogPos for non-artificial events in MariaDB 11.4+ (#1052)
* fix(replication): calculate LogPos for non-artificial events in MariaDB 11.4+
* fix(replication): add configuration parameter to enable calculation of LogPos for non-artificial events in MariaDB 11.4+
Copy file name to clipboardExpand all lines: README.md
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,7 +133,33 @@ 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 `MariaDBDynamicLogPos` 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
+
MariaDBDynamicLogPos: true,
152
+
}
153
+
```
154
+
155
+
**Behavior:**
156
+
- When `MariaDBDynamicLogPos` 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.
0 commit comments