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

Update go to v1.21 #346

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: '1.21.3'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This question applies to all the GHA workflows:

Do we need to be that explicit about the version? I would say stating 1.21 would be enough, regardless of the patch version. WDYT?


- name: Building Ghostferry
run: .github/workflows/build-deb.sh
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
CI: "true"
MYSQL_VERSION: "8.0"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: '1.21.3'

- name: Starting up MySQL
run: .github/workflows/start-mysql.sh
Expand All @@ -33,12 +33,12 @@ jobs:
CI: "true"
MYSQL_VERSION: "8.0"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: '1.21.3'

- name: Starting up MySQL
run: .github/workflows/start-mysql.sh
Expand All @@ -53,12 +53,12 @@ jobs:
BUNDLE_WITHOUT: "development"
MYSQL_VERSION: "8.0"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Golang
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: '1.21.3'

- name: Setup Ruby
uses: ruby/setup-ruby@v1
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests_5.7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
CI: "true"
MYSQL_VERSION: "5.7"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: '1.21.3'

- name: Starting up MySQL
run: .github/workflows/start-mysql.sh
Expand All @@ -33,12 +33,12 @@ jobs:
CI: "true"
MYSQL_VERSION: "5.7"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: '1.21.3'

- name: Starting up MySQL
run: .github/workflows/start-mysql.sh
Expand All @@ -53,12 +53,12 @@ jobs:
MYSQL_VERSION: "5.7"
BUNDLE_WITHOUT: "development"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Golang
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: '1.21.3'

- name: Setup Ruby
uses: ruby/setup-ruby@v1
Expand Down
1 change: 1 addition & 0 deletions binlog_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (s *BinlogStreamer) createBinlogSyncer() error {
TLSConfig: tlsConfig,
UseDecimal: true,
TimestampStringLocation: time.UTC,
Logger: s.logger,
}

s.binlogSyncer = replication.NewBinlogSyncer(syncerConfig)
Expand Down
13 changes: 7 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ type ControlServerConfig struct {
ServerBindAddr string

// Path to `web` base dir
WebBasedir string
WebBasedir string

// TODO: refactor control server config out of the base ferry at some point
// This adds optional buttons in the web ui that runs a script located at the
Expand Down Expand Up @@ -319,7 +319,8 @@ func (c *ControlServerConfig) Validate() error {

// SchemaName => TableName => ColumnName => CompressionAlgorithm
// Example: blog1 => articles => body => snappy
// (SELECT body FROM blog1.articles => returns compressed blob)
//
// (SELECT body FROM blog1.articles => returns compressed blob)
type ColumnCompressionConfig map[string]map[string]map[string]string

func (c ColumnCompressionConfig) CompressedColumnsFor(schemaName, tableName string) map[string]string {
Expand Down Expand Up @@ -835,7 +836,7 @@ func (c *Config) ValidateConfig() error {
return fmt.Errorf("control_server: %s", err)
}

if c.DBWriteRetries == 0 {
if c.DBWriteRetries == 0 {
c.DBWriteRetries = 5
}

Expand Down Expand Up @@ -870,7 +871,7 @@ func (c *Config) ValidateConfig() error {
return nil
}

func (c *Config) checkForDeprecatedConfig() {
func (c *Config) checkForDeprecatedConfig() {
if c.DataIterationBatchSize != 0 {
c.logDeprecated("DataIterationBatchSize", "UpdatableConfig.DataIterationBatchSize")
c.UpdatableConfig.DataIterationBatchSize = c.DataIterationBatchSize
Expand All @@ -888,11 +889,11 @@ func (c *Config) checkForDeprecatedConfig() {

if len(c.ControlServerCustomScripts) != 0 {
c.logDeprecated("ControlServerCustomScripts", "ControlServerConfig.CustomScripts")
c.ControlServerConfig.CustomScripts= c.ControlServerCustomScripts
c.ControlServerConfig.CustomScripts = c.ControlServerCustomScripts
}
}

func (c *Config) logDeprecated(deprecatedConfig string, newConfig string) {
func (c *Config) logDeprecated(deprecatedConfig string, newConfig string) {
logrus.Warnf("Config.%s is deprecated in favour of Config.%s", deprecatedConfig, newConfig)
}

Expand Down
5 changes: 2 additions & 3 deletions control_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type ControlServerTableStatus struct {
LastSuccessfulPaginationKey uint64
TargetPaginationKey uint64

BatchSize uint64
BatchSize uint64
}

type CustomScriptStatus struct {
Expand Down Expand Up @@ -214,7 +214,7 @@ func (this *ControlServer) HandleStatus(w http.ResponseWriter, r *http.Request)

// Converting time values to seconds manually for json output
status.TimeTaken = status.TimeTaken / time.Second
status.BinlogStreamerLag = status.BinlogStreamerLag / time.Second
status.BinlogStreamerLag = status.BinlogStreamerLag / time.Second
status.ETA = status.ETA / time.Second

w.Header().Set("Content-Type", "application/json")
Expand Down Expand Up @@ -295,7 +295,6 @@ func (this *ControlServer) fetchStatus() *ControlServerStatus {
LastSuccessfulPaginationKey: lastSuccessfulPaginationKey,
TargetPaginationKey: tableProgress.TargetPaginationKey,
BatchSize: tableProgress.BatchSize,

}

tablesGroupByStatus[tableStatus] = append(tablesGroupByStatus[tableStatus], controlStatus)
Expand Down
2 changes: 1 addition & 1 deletion copydb/test/copydb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (t *CopydbTestSuite) TestCreateDatabasesAndTablesAlreadyExists() {
testhelpers.SeedInitialData(t.ferry.TargetDB, renamedSchemaName, renamedTableName, 1)

err = t.copydbFerry.CreateDatabasesAndTables()
t.Require().EqualError(err, "Error 1050: Table 'test_table_1_renamed' already exists")
t.Require().EqualError(err, "Error 1050 (42S01): Table 'test_table_1_renamed' already exists")
}

func (t *CopydbTestSuite) TestCreateDatabasesAndTablesAlreadyExistsAllowed() {
Expand Down
4 changes: 2 additions & 2 deletions cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type CursorConfig struct {
DB *sql.DB
Throttler Throttler

ColumnsToSelect []string
BuildSelect func([]string, *TableSchema, uint64, uint64) (squirrel.SelectBuilder, error)
ColumnsToSelect []string
BuildSelect func([]string, *TableSchema, uint64, uint64) (squirrel.SelectBuilder, error)
// BatchSize is a pointer to the BatchSize in Config.UpdatableConfig which can be independently updated from this code.
// Having it as a pointer allows the updated value to be read without needing additional code to copy the batch size value into the cursor config for each cursor we create.
BatchSize *uint64
Expand Down
2 changes: 1 addition & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ up:
- ruby: "3.2.2"
- bundler
- go:
version: "1.16"
version: "1.21.3"
- podman
- custom:
name: Go Dependencies
Expand Down
24 changes: 12 additions & 12 deletions dml_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ type RowData []interface{}
// https://github.com/Shopify/ghostferry/issues/165.
//
// In summary:
// - This code receives values from both go-sql-driver/mysql and
// go-mysql-org/go-mysql.
// - go-sql-driver/mysql gives us int64 for signed integer, and uint64 in a byte
// slice for unsigned integer.
// - go-mysql-org/go-mysql gives us int64 for signed integer, and uint64 for
// unsigned integer.
// - We currently make this function deal with both cases. In the future we can
// investigate alternative solutions.
// - This code receives values from both go-sql-driver/mysql and
// go-mysql-org/go-mysql.
// - go-sql-driver/mysql gives us int64 for signed integer, and uint64 in a byte
// slice for unsigned integer.
// - go-mysql-org/go-mysql gives us int64 for signed integer, and uint64 for
// unsigned integer.
// - We currently make this function deal with both cases. In the future we can
// investigate alternative solutions.
func (r RowData) GetUint64(colIdx int) (uint64, error) {
u64, ok := Uint64Value(r[colIdx])
if ok {
Expand Down Expand Up @@ -501,10 +501,10 @@ func Int64Value(value interface{}) (int64, bool) {
//
// This is specifically mentioned in the the below link:
//
// When BINARY values are stored, they are right-padded with the pad value
// to the specified length. The pad value is 0x00 (the zero byte). Values
// are right-padded with 0x00 for inserts, and no trailing bytes are removed
// for retrievals.
// When BINARY values are stored, they are right-padded with the pad value
// to the specified length. The pad value is 0x00 (the zero byte). Values
// are right-padded with 0x00 for inserts, and no trailing bytes are removed
// for retrievals.
//
// ref: https://dev.mysql.com/doc/refman/5.7/en/binary-varbinary.html
func appendEscapedString(buffer []byte, value string, rightPadToLengthWithZeroBytes int) []byte {
Expand Down
38 changes: 22 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
module github.com/Shopify/ghostferry

go 1.14
go 1.21

require (
github.com/DataDog/datadog-go v4.8.2+incompatible
github.com/Masterminds/squirrel v0.0.0-20180620232226-b127ed9be034
github.com/Masterminds/squirrel v1.5.4
github.com/go-mysql-org/go-mysql v1.7.0
github.com/go-sql-driver/mysql v1.7.1
github.com/golang/snappy v0.0.4
github.com/gorilla/mux v1.8.0
github.com/shopspring/decimal v1.3.1
github.com/siddontang/go-log v0.0.0-20190221022429-1e957dd83bed
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.0
)

require (
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/go-mysql-org/go-mysql v1.4.1-0.20220112102103-b3f1a27311d8
github.com/go-sql-driver/mysql v1.5.0
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v1.6.1
github.com/lann/builder v0.0.0-20180216234317-1b87b36280d0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.3.0 // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712 // indirect
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.4.0
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 // indirect
github.com/pingcap/errors v0.11.5-0.20210425183316-da1aaba5fb63 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/sys v0.13.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading