@@ -235,13 +235,15 @@ func (a *binlogReplicaApplier) startReplicationEventStream(ctx *sql.Context, con
235
235
return err
236
236
}
237
237
238
- if position == nil {
238
+ if position != nil {
239
+ ctx .GetLogger ().Debugf ("Loaded position from position store: %s" , position .String ())
240
+ } else {
239
241
// If the positionStore doesn't have a record of executed GTIDs, check to see if the gtid_purged system
240
242
// variable is set. If it holds a GTIDSet, then we use that as our starting position. As part of loading
241
243
// a mysqldump onto a replica, gtid_purged will be set to indicate where to start replication.
242
244
_ , value , ok := sql .SystemVariables .GetGlobal ("gtid_purged" )
243
245
gtidPurged , isString := value .(string )
244
- if ok && value != nil && isString {
246
+ if ok && value != nil && isString && gtidPurged != "" {
245
247
// Starting in MySQL 8.0, when setting the GTID_PURGED sys variable, if the new value starts with '+', then
246
248
// the specified GTID Set value is added to the current GTID Set value to get a new GTID Set that contains
247
249
// all the previous GTIDs, plus the new ones from the current assignment. Dolt doesn't support this
@@ -253,25 +255,31 @@ func (a *binlogReplicaApplier) startReplicationEventStream(ctx *sql.Context, con
253
255
gtidPurged = gtidPurged [1 :]
254
256
}
255
257
256
- purged , err := mysql .ParsePosition (mysqlFlavor , gtidPurged )
258
+ flavor := mysqlFlavor
259
+ if conn .IsMariaDB () {
260
+ flavor = mariadbFlavor
261
+ }
262
+ purged , err := mysql .ParsePosition (flavor , gtidPurged )
257
263
if err != nil {
264
+ ctx .GetLogger ().Errorf ("unable to parse gtid_purged: %s" , err .Error ())
258
265
return err
259
266
}
260
- position = & purged
267
+
268
+ if ! purged .IsZero () {
269
+ position = & purged
270
+ }
261
271
}
262
272
}
263
273
274
+ // If we don't have a position that we previously stored, then initialize an empty position.
264
275
if position == nil {
265
- // If we still don't have any record of executed GTIDs, we create a GTIDSet with just one transaction ID
266
- // for the 0000 server ID. There doesn't seem to be a cleaner way of saying "start at the very beginning".
267
- //
268
- // Also... "starting position" is a bit of a misnomer – it's actually the processed GTIDs, which
269
- // indicate the NEXT GTID where replication should start, but it's not as direct as specifying
270
- // a starting position, like the Vitess function signature seems to suggest.
271
- gtid := mysql.Mysql56GTID {
272
- Sequence : 1 ,
276
+ if conn .IsMariaDB () {
277
+ ctx .GetLogger ().Infof ("Initializing empty GTID set (for MariaDB)" )
278
+ position = & mysql.Position {GTIDSet : mysql.MariadbGTIDSet {}}
279
+ } else {
280
+ ctx .GetLogger ().Infof ("Initializing empty GTID set" )
281
+ position = & mysql.Position {GTIDSet : mysql.Mysql56GTIDSet {}}
273
282
}
274
- position = & mysql.Position {GTIDSet : gtid .GTIDSet ()}
275
283
}
276
284
277
285
a .currentPosition = position
@@ -485,7 +493,7 @@ func (a *binlogReplicaApplier) processBinlogEvent(ctx *sql.Context, engine *gms.
485
493
return err
486
494
}
487
495
if isBegin {
488
- ctx .GetLogger ().Errorf ("unsupported binlog protocol message: GTID event with 'isBegin' set to true" )
496
+ ctx .GetLogger ().Warnf ("unsupported binlog protocol message: GTID event with 'isBegin' set to true" )
489
497
}
490
498
ctx .GetLogger ().WithFields (logrus.Fields {
491
499
"gtid" : gtid ,
@@ -550,6 +558,14 @@ func (a *binlogReplicaApplier) processBinlogEvent(ctx *sql.Context, engine *gms.
550
558
return err
551
559
}
552
560
561
+ case event .Bytes ()[4 ] == 0xA1 :
562
+ // https://mariadb.com/kb/en/binlog_checkpoint_event/
563
+ ctx .GetLogger ().Warnf ("received unsupported event: CHECKPOINT_EVENT" )
564
+
565
+ case event .Bytes ()[4 ] == 0xA3 :
566
+ // https://mariadb.com/kb/en/gtid_list_event/
567
+ ctx .GetLogger ().Warnf ("received unsupported event: GTID_LIST_EVENT" )
568
+
553
569
default :
554
570
// We can't access the bytes directly because these non-interface types in Vitess are not exposed.
555
571
// Having a Bytes() or Type() method on the Vitess interface would let us clean this up.
0 commit comments