Skip to content

Commit

Permalink
Merge pull request #8211 from dolthub/fulghum/binlog-bugfix
Browse files Browse the repository at this point in the history
Bug fix: binlog replication: logging levels, use MySQL's older date serialization format
  • Loading branch information
fulghum authored Aug 5, 2024
2 parents 2e10964 + fb96dd2 commit a0a2c5f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (streamer *binlogStreamer) startStream(ctx *sql.Context, conn *mysql.Conn,
err := streamer.streamNextEvents(ctx, conn,
*binlogFormat, binlogEventMeta, filepath.Dir(logfile), executedGtids)
if err == io.EOF {
logrus.Debug("End of binlog file! Pausing for new events...")
logrus.Trace("End of binlog file! Pausing for new events...")
time.Sleep(250 * time.Millisecond)
} else if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,11 @@ func (b *binlogProducer) createRowEvents(ctx *sql.Context, tableDeltas []diff.Ta
func (b *binlogProducer) currentGtidPosition() string {
b.mu.Lock()
defer b.mu.Unlock()

if b.gtidPosition == nil {
return ""
}

return b.gtidPosition.String()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ func (d dateSerializer) serialize(_ *sql.Context, typ sql.Type, descriptor val.T
}

func (d dateSerializer) metadata(_ *sql.Context, typ sql.Type) (byte, uint16) {
return mysql.TypeNewDate, 0
// NOTE: MySQL still sends the old date type (not mysql.TypeNewDate), so for compatibility we use that here
return mysql.TypeDate, 0
}

// timestampSerializer loads a TIMESTAMP type value from Dolt's storage and encodes it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func TestDateSerializer(t *testing.T) {
require.NoError(t, err)
require.Equal(t, []byte{0x43, 0xb5, 0x0f}, bytes)
typeId, metadata := s.metadata(nil, gmstypes.Date)
require.EqualValues(t, mysql.TypeNewDate, typeId)
require.EqualValues(t, mysql.TypeDate, typeId)
require.EqualValues(t, 0, metadata)
}

Expand Down

0 comments on commit a0a2c5f

Please sign in to comment.