Skip to content

Commit

Permalink
Merge pull request #99 from SihangYu/sihang-mysql8
Browse files Browse the repository at this point in the history
fix(mysql): Replace the deprecated system variable tx_isolation in MySQL 8.0
  • Loading branch information
tedpennings authored Oct 3, 2024
2 parents a76ce32 + 4c5b73f commit 5ca6740
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- docker

install:
- docker pull mysql:5.6
- docker pull mysql:8.0
- go get golang.org/x/lint/golint
- go get github.com/kisielk/errcheck

Expand Down
4 changes: 2 additions & 2 deletions docs/How-to-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ for other users to get up and running quickly.
## Prerequisites

* [Spinnaker]
* MySQL (5.6 or later)
* MySQL (8.0 or later)

To use this version of Chaos Monkey, you must be using [Spinnaker] to manage your applications. Spinnaker is the
continuous delivery platform that we use at Netflix.

Chaos Monkey also requires a MySQL-compatible database, version 5.6 or later.
Chaos Monkey also requires a MySQL-compatible database, version 8.0 or later.

[Spinnaker]: http://www.spinnaker.io/

Expand Down
2 changes: 1 addition & 1 deletion docs/Running-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ describes how to start both of those up using Docker containers
This will start up a MySQL container with the root password as `password`.

```bash
docker run -e MYSQL_ROOT_PASSWORD=password -p3306:3306 mysql:5.6
docker run -e MYSQL_ROOT_PASSWORD=password -p3306:3306 mysql:8.0
```
6 changes: 3 additions & 3 deletions docs/dev/Running-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ root:password@tcp(127.0.0.1:3306)/
### Testing with Docker

The simplest way to run these tests is to install Docker on your local machine.
These tests use the `mysql:5.6` container (version 5.6 is used to ensure
These tests use the `mysql:8.0` container (version 8.0 is used to ensure
compatibility with [Amazon Aurora][1]).

Note that if you are on macOS, you must use [Docker for Mac][2], not Docker
Toolbox. Otherwise, the Docker containers will not be accessible at 127.0.0.1.


If you want to run these tests, ensure you have Docker installed locally, and
grab the mysql:5.6 container:
grab the mysql:8.0 container:

```bash
docker pull mysql:5.6
docker pull mysql:8.0
```

Then run the tests with the `docker` tag, like this:
Expand Down
2 changes: 1 addition & 1 deletion mysql/checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//go:build docker
// +build docker

// The tests in this package use docker to test against a mysql:5.6 database
// The tests in this package use docker to test against a mysql:8.0 database
// By default, the tests are off unless you pass the "-tags docker" flag
// when running the test.

Expand Down
10 changes: 5 additions & 5 deletions mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TxDeadlock(err error) bool {
switch err := errors.Cause(err).(type) {
case *mysql.MySQLError:
// ER_LOCK_DEADLOCK
// See: https://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html
// See: https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html#error_er_lock_deadlock
return err.Number == 1213
default:
return false
Expand Down Expand Up @@ -242,10 +242,10 @@ func schedExists(tx *sql.Tx, date time.Time) (result bool, err error) {
// See: https://github.com/go-sql-driver/mysql#dsn-data-source-name
func dsn(host string, port int, user string, password string, dbname string) string {
params := map[string]string{
"tx_isolation": "SERIALIZABLE", // we need serializable transactions for atomic test & set behavior
"parseTime": "true", // enable us to use sql.Rows.Scan to read time.Time objects from queries
"loc": "UTC", // Scan'd time.Times should be treated as being in UTC time zone
"time_zone": "UTC", // MySQL should interpret DATETIME values as being in UTC
"transaction_isolation": "SERIALIZABLE", // we need serializable transactions for atomic test & set behavior
"parseTime": "true", // enable us to use sql.Rows.Scan to read time.Time objects from queries
"loc": "UTC", // Scan'd time.Times should be treated as being in UTC time zone
"time_zone": "UTC", // MySQL should interpret DATETIME values as being in UTC
}

var ss []string
Expand Down
4 changes: 2 additions & 2 deletions mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//go:build docker
// +build docker

// The tests in this package use docker to test against a mysql:5.6 database
// The tests in this package use docker to test against a mysql:8.0 database
// By default, the tests are off unless you pass the "-tags docker" flag
// when running the test.
//
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestMain(m *testing.M) {
// startMySQLContainer starts a MySQL docker container
// Returns the Cmd object associated with the process
func startMySQLContainer() (*exec.Cmd, error) {
cmd := exec.Command("docker", "run", "-e", "MYSQL_ROOT_PASSWORD="+password, fmt.Sprintf("-p3306:%d", port), "mysql:5.6")
cmd := exec.Command("docker", "run", "-e", "MYSQL_ROOT_PASSWORD="+password, fmt.Sprintf("-p3306:%d", port), "mysql:8.0")
pipe, err := cmd.StderrPipe()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion mysql/schedstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//go:build docker
// +build docker

// The tests in this package use docker to test against a mysql:5.6 database
// The tests in this package use docker to test against a mysql:8.0 database
// By default, the tests are off unless you pass the "-tags docker" flag
// when running the test.

Expand Down

0 comments on commit 5ca6740

Please sign in to comment.