Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2

- name: Set up Go 1.12
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
version: 1.12
id: go
go-version: 1.14

- name: Build
run: script/cibuild
7 changes: 3 additions & 4 deletions .github/workflows/replica-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2

- name: Set up Go 1.12
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
version: 1.12
id: go
go-version: 1.14

- name: migration tests
run: script/cibuild-gh-ost-replica-tests
2 changes: 1 addition & 1 deletion Dockerfile.packaging
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#

FROM golang:1.12.6
FROM golang:1.14.4

RUN apt-get update
RUN apt-get install -y ruby ruby-dev rubygems build-essential
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.12.1
FROM golang:1.14.4
LABEL maintainer="github@github.com"

RUN apt-get update
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Please see [Coding gh-ost](doc/coding-ghost.md) for a guide to getting started d

[Download latest release here](https://github.com/github/gh-ost/releases/latest)

`gh-ost` is a Go project; it is built with Go `1.12` and above. To build on your own, use either:
`gh-ost` is a Go project; it is built with Go `1.14` and above. To build on your own, use either:
- [script/build](https://github.com/github/gh-ost/blob/master/script/build) - this is the same build script used by CI hence the authoritative; artifact is `./bin/gh-ost` binary.
- [build.sh](https://github.com/github/gh-ost/blob/master/build.sh) for building `tar.gz` artifacts in `/tmp/gh-ost`

Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function build {
GOOS=$3
GOARCH=$4

if ! go version | egrep -q 'go(1\.1[234])' ; then
echo "go version must be 1.12 or above"
if ! go version | egrep -q 'go(1\.1[456])' ; then
echo "go version must be 1.14 or above"
exit 1
fi

Expand Down
21 changes: 21 additions & 0 deletions go/base/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/github/gh-ost/go/mysql"
"github.com/github/gh-ost/go/sql"
"github.com/outbrain/golib/log"

"gopkg.in/gcfg.v1"
gcfgscanner "gopkg.in/gcfg.v1/scanner"
Expand Down Expand Up @@ -217,6 +218,25 @@ type MigrationContext struct {
ForceTmpTableName string

recentBinlogCoordinates mysql.BinlogCoordinates

Log Logger
}

type Logger interface {
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Warning(args ...interface{}) error
Warningf(format string, args ...interface{}) error
Error(args ...interface{}) error
Errorf(format string, args ...interface{}) error
Errore(err error) error
Fatal(args ...interface{}) error
Fatalf(format string, args ...interface{}) error
Fatale(err error) error
SetLevel(level log.LogLevel)
SetPrintStackTrace(printStackTraceFlag bool)
}

type ContextConfig struct {
Expand Down Expand Up @@ -251,6 +271,7 @@ func NewMigrationContext() *MigrationContext {
pointOfInterestTimeMutex: &sync.Mutex{},
ColumnRenameMap: make(map[string]string),
PanicAbort: make(chan error),
Log: NewDefaultLogger(),
}
}

Expand Down
73 changes: 73 additions & 0 deletions go/base/default_logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package base

import (
"github.com/outbrain/golib/log"
)

type simpleLogger struct{}

func NewDefaultLogger() *simpleLogger {
return &simpleLogger{}
}

func (*simpleLogger) Debug(args ...interface{}) {
log.Debug(args[0].(string), args[1:])
return
}

func (*simpleLogger) Debugf(format string, args ...interface{}) {
log.Debugf(format, args...)
return
}

func (*simpleLogger) Info(args ...interface{}) {
log.Info(args[0].(string), args[1:])
return
}

func (*simpleLogger) Infof(format string, args ...interface{}) {
log.Infof(format, args...)
return
}

func (*simpleLogger) Warning(args ...interface{}) error {
return log.Warning(args[0].(string), args[1:])
}

func (*simpleLogger) Warningf(format string, args ...interface{}) error {
return log.Warningf(format, args...)
}

func (*simpleLogger) Error(args ...interface{}) error {
return log.Error(args[0].(string), args[1:])
}

func (*simpleLogger) Errorf(format string, args ...interface{}) error {
return log.Errorf(format, args...)
}

func (*simpleLogger) Errore(err error) error {
return log.Errore(err)
}

func (*simpleLogger) Fatal(args ...interface{}) error {
return log.Fatal(args[0].(string), args[1:])
}

func (*simpleLogger) Fatalf(format string, args ...interface{}) error {
return log.Fatalf(format, args...)
}

func (*simpleLogger) Fatale(err error) error {
return log.Fatale(err)
}

func (*simpleLogger) SetLevel(level log.LogLevel) {
log.SetLevel(level)
return
}

func (*simpleLogger) SetPrintStackTrace(printStackTraceFlag bool) {
log.SetPrintStackTrace(printStackTraceFlag)
return
}
3 changes: 1 addition & 2 deletions go/base/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

gosql "database/sql"
"github.com/github/gh-ost/go/mysql"
"github.com/outbrain/golib/log"
)

var (
Expand Down Expand Up @@ -86,7 +85,7 @@ func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig,
}

if connectionConfig.Key.Port == port || (extraPort > 0 && connectionConfig.Key.Port == extraPort) {
log.Infof("connection validated on %+v", connectionConfig.Key)
migrationContext.Log.Infof("connection validated on %+v", connectionConfig.Key)
return version, nil
} else if extraPort == 0 {
return "", fmt.Errorf("Unexpected database port reported: %+v", port)
Expand Down
13 changes: 7 additions & 6 deletions go/binlog/gomysql_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
"github.com/github/gh-ost/go/mysql"
"github.com/github/gh-ost/go/sql"

"github.com/outbrain/golib/log"
gomysql "github.com/siddontang/go-mysql/mysql"
"github.com/siddontang/go-mysql/replication"
"golang.org/x/net/context"
)

type GoMySQLReader struct {
migrationContext *base.MigrationContext
connectionConfig *mysql.ConnectionConfig
binlogSyncer *replication.BinlogSyncer
binlogStreamer *replication.BinlogStreamer
Expand All @@ -30,6 +30,7 @@ type GoMySQLReader struct {

func NewGoMySQLReader(migrationContext *base.MigrationContext) (binlogReader *GoMySQLReader, err error) {
binlogReader = &GoMySQLReader{
migrationContext: migrationContext,
connectionConfig: migrationContext.InspectorConnectionConfig,
currentCoordinates: mysql.BinlogCoordinates{},
currentCoordinatesMutex: &sync.Mutex{},
Expand Down Expand Up @@ -57,11 +58,11 @@ func NewGoMySQLReader(migrationContext *base.MigrationContext) (binlogReader *Go
// ConnectBinlogStreamer
func (this *GoMySQLReader) ConnectBinlogStreamer(coordinates mysql.BinlogCoordinates) (err error) {
if coordinates.IsEmpty() {
return log.Errorf("Empty coordinates at ConnectBinlogStreamer()")
return this.migrationContext.Log.Errorf("Empty coordinates at ConnectBinlogStreamer()")
}

this.currentCoordinates = coordinates
log.Infof("Connecting binlog streamer at %+v", this.currentCoordinates)
this.migrationContext.Log.Infof("Connecting binlog streamer at %+v", this.currentCoordinates)
// Start sync with specified binlog file and position
this.binlogStreamer, err = this.binlogSyncer.StartSync(gomysql.Position{this.currentCoordinates.LogFile, uint32(this.currentCoordinates.LogPos)})

Expand All @@ -78,7 +79,7 @@ func (this *GoMySQLReader) GetCurrentBinlogCoordinates() *mysql.BinlogCoordinate
// StreamEvents
func (this *GoMySQLReader) handleRowsEvent(ev *replication.BinlogEvent, rowsEvent *replication.RowsEvent, entriesChannel chan<- *BinlogEntry) error {
if this.currentCoordinates.SmallerThanOrEquals(&this.LastAppliedRowsEventHint) {
log.Debugf("Skipping handled query at %+v", this.currentCoordinates)
this.migrationContext.Log.Debugf("Skipping handled query at %+v", this.currentCoordinates)
return nil
}

Expand Down Expand Up @@ -147,14 +148,14 @@ func (this *GoMySQLReader) StreamEvents(canStopStreaming func() bool, entriesCha
defer this.currentCoordinatesMutex.Unlock()
this.currentCoordinates.LogFile = string(rotateEvent.NextLogName)
}()
log.Infof("rotate to next log from %s:%d to %s", this.currentCoordinates.LogFile, int64(ev.Header.LogPos), rotateEvent.NextLogName)
this.migrationContext.Log.Infof("rotate to next log from %s:%d to %s", this.currentCoordinates.LogFile, int64(ev.Header.LogPos), rotateEvent.NextLogName)
} else if rowsEvent, ok := ev.Event.(*replication.RowsEvent); ok {
if err := this.handleRowsEvent(ev, rowsEvent, entriesChannel); err != nil {
return err
}
}
}
log.Debugf("done streaming events")
this.migrationContext.Log.Debugf("done streaming events")

return nil
}
Expand Down
Loading