Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binlog compress #1447

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ go 1.22.0

require (
github.com/go-ini/ini v1.67.0
github.com/go-mysql-org/go-mysql v1.7.0
github.com/go-mysql-org/go-mysql v1.8.0
github.com/go-sql-driver/mysql v1.8.1
github.com/google/uuid v1.6.0
github.com/openark/golib v0.0.0-20210531070646-355f37940af8
@@ -20,6 +20,7 @@ require (
dario.cat/mergo v1.0.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/containerd v1.7.18 // indirect
@@ -35,9 +36,9 @@ require (
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
@@ -48,13 +49,15 @@ require (
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pingcap/errors v0.11.5-0.20210425183316-da1aaba5fb63 // indirect
github.com/pingcap/errors v0.11.5-0.20221009092201-b66cddb77c32 // indirect
github.com/pingcap/log v1.1.1-0.20230317032135-a0d097d16e22 // indirect
github.com/pingcap/tidb/pkg/parser v0.0.0-20231103042308-035ad5ccbe67 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
@@ -65,8 +68,12 @@ require (
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/sys v0.28.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
79 changes: 33 additions & 46 deletions go.sum

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions go/binlog/gomysql_reader.go
Original file line number Diff line number Diff line change
@@ -160,6 +160,10 @@ func (this *GoMySQLReader) StreamEvents(canStopStreaming func() bool, entriesCha
if err := this.handleRowsEvent(ev, binlogEvent, entriesChannel); err != nil {
return err
}
case *replication.TransactionPayloadEvent:
if err := this.handleTransactionPayloadEvent(binlogEvent, entriesChannel); err != nil {
return err
}
}
}
this.migrationContext.Log.Debugf("done streaming events")
@@ -171,3 +175,62 @@ func (this *GoMySQLReader) Close() error {
this.binlogSyncer.Close()
return nil
}

// handleLoadQueryEvent
func (this *GoMySQLReader) handleTransactionPayloadEvent(rowsEvents *replication.TransactionPayloadEvent, entriesChannel chan<- *BinlogEntry) (err error) {
if this.currentCoordinates.IsLogPosOverflowBeyond4Bytes(&this.LastAppliedRowsEventHint) {
return fmt.Errorf("Unexpected rows event at %+v, the binlog end_log_pos is overflow 4 bytes", this.currentCoordinates)
}
if this.currentCoordinates.SmallerThanOrEquals(&this.LastAppliedRowsEventHint) {
this.migrationContext.Log.Debugf("Skipping handled query at %+v", this.currentCoordinates)
return nil
}
for _, ev := range rowsEvents.Events {
switch rowsEvent := ev.Event.(type) {
case *replication.RowsEvent:
// if err := this.handleRowsEvent(ev, binlogEvent, entriesChannel); err != nil {
// return err
// }
dml := ToEventDML(ev.Header.EventType.String())
if dml == NotDML {
return fmt.Errorf("Unknown DML type: %s", ev.Header.EventType.String())
}
for i, row := range rowsEvent.Rows {
if dml == UpdateDML && i%2 == 1 {
// An update has two rows (WHERE+SET)
// We do both at the same time
continue
}
binlogEntry := NewBinlogEntryAt(this.currentCoordinates)
binlogEntry.DmlEvent = NewBinlogDMLEvent(
string(rowsEvent.Table.Schema),
string(rowsEvent.Table.Table),
dml,
)
switch dml {
case InsertDML:
{
binlogEntry.DmlEvent.NewColumnValues = sql.ToColumnValues(row)
}
case UpdateDML:
{
binlogEntry.DmlEvent.WhereColumnValues = sql.ToColumnValues(row)
binlogEntry.DmlEvent.NewColumnValues = sql.ToColumnValues(rowsEvent.Rows[i+1])
}
case DeleteDML:
{
binlogEntry.DmlEvent.WhereColumnValues = sql.ToColumnValues(row)
}
}
// The channel will do the throttling. Whoever is reading from the channel
// decides whether action is taken synchronously (meaning we wait before
// next iteration) or asynchronously (we keep pushing more events)
// In reality, reads will be synchronous
entriesChannel <- binlogEntry
}

}
}
this.LastAppliedRowsEventHint = this.currentCoordinates
return
}
29 changes: 29 additions & 0 deletions vendor/github.com/Masterminds/semver/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions vendor/github.com/Masterminds/semver/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/Masterminds/semver/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions vendor/github.com/Masterminds/semver/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

194 changes: 194 additions & 0 deletions vendor/github.com/Masterminds/semver/README.md
44 changes: 44 additions & 0 deletions vendor/github.com/Masterminds/semver/appveyor.yml
24 changes: 24 additions & 0 deletions vendor/github.com/Masterminds/semver/collection.go
423 changes: 423 additions & 0 deletions vendor/github.com/Masterminds/semver/constraints.go

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions vendor/github.com/Masterminds/semver/doc.go
425 changes: 425 additions & 0 deletions vendor/github.com/Masterminds/semver/version.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions vendor/github.com/Masterminds/semver/version_fuzz.go
124 changes: 89 additions & 35 deletions vendor/github.com/go-mysql-org/go-mysql/client/auth.go
209 changes: 202 additions & 7 deletions vendor/github.com/go-mysql-org/go-mysql/client/conn.go
207 changes: 171 additions & 36 deletions vendor/github.com/go-mysql-org/go-mysql/client/pool.go
60 changes: 60 additions & 0 deletions vendor/github.com/go-mysql-org/go-mysql/client/pool_options.go
27 changes: 14 additions & 13 deletions vendor/github.com/go-mysql-org/go-mysql/client/resp.go
28 changes: 27 additions & 1 deletion vendor/github.com/go-mysql-org/go-mysql/mysql/const.go
45 changes: 38 additions & 7 deletions vendor/github.com/go-mysql-org/go-mysql/mysql/field.go
4 changes: 4 additions & 0 deletions vendor/github.com/go-mysql-org/go-mysql/mysql/gtid.go
65 changes: 42 additions & 23 deletions vendor/github.com/go-mysql-org/go-mysql/mysql/mariadb_gtid.go
9 changes: 8 additions & 1 deletion vendor/github.com/go-mysql-org/go-mysql/mysql/position.go
38 changes: 38 additions & 0 deletions vendor/github.com/go-mysql-org/go-mysql/mysql/util.go
201 changes: 189 additions & 12 deletions vendor/github.com/go-mysql-org/go-mysql/packet/conn.go
46 changes: 34 additions & 12 deletions vendor/github.com/go-mysql-org/go-mysql/replication/backup.go
32 changes: 31 additions & 1 deletion vendor/github.com/go-mysql-org/go-mysql/replication/const.go
37 changes: 30 additions & 7 deletions vendor/github.com/go-mysql-org/go-mysql/replication/event.go
104 changes: 97 additions & 7 deletions vendor/github.com/go-mysql-org/go-mysql/replication/json_binary.go
47 changes: 44 additions & 3 deletions vendor/github.com/go-mysql-org/go-mysql/replication/parser.go
Loading