Skip to content

Commit 9268cc0

Browse files
authored
Merge branch 'master' into dependabot/github_actions/actions/setup-go-6
2 parents afc5979 + 57df4b4 commit 9268cc0

File tree

8 files changed

+394
-234
lines changed

8 files changed

+394
-234
lines changed

.github/workflows/replica-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717

18+
- name: Install sysbench
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y sysbench
22+
1823
- name: Setup environment
1924
run: script/docker-gh-ost-replica-tests up
2025

doc/local-tests.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,11 @@ TEST_MYSQL_IMAGE="mysql-server:8.0.16" ./script/docker-gh-ost-replica-tests up
3434
# cleanup containers
3535
./script/docker-gh-ost-replica-tests down
3636
```
37+
38+
Pass the `-t` flag to run the tests with a toxiproxy between gh-ost and the MySQL replica. This simulates network conditions where MySQL connections are closed unexpectedly.
39+
40+
```shell
41+
# run tests with toxiproxy
42+
./script/docker-gh-ost-replica-tests up -t
43+
./script/docker-gh-ost-replica-tests run -t
44+
```

go/cmd/gh-ost/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func main() {
143143
flag.BoolVar(&migrationContext.IncludeTriggers, "include-triggers", false, "When true, the triggers (if exist) will be created on the new table")
144144
flag.StringVar(&migrationContext.TriggerSuffix, "trigger-suffix", "", "Add a suffix to the trigger name (i.e '_v2'). Requires '--include-triggers'")
145145
flag.BoolVar(&migrationContext.RemoveTriggerSuffix, "remove-trigger-suffix-if-exists", false, "Remove given suffix from name of trigger. Requires '--include-triggers' and '--trigger-suffix'")
146+
flag.BoolVar(&migrationContext.SkipPortValidation, "skip-port-validation", false, "Skip port validation for MySQL connections")
146147

147148
maxLoad := flag.String("max-load", "", "Comma delimited status-name=threshold. e.g: 'Threads_running=100,Threads_connected=500'. When status exceeds threshold, app throttles writes")
148149
criticalLoad := flag.String("critical-load", "", "Comma delimited status-name=threshold, same format as --max-load. When status exceeds threshold, app panics and quits")

go/logic/applier.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package logic
88
import (
99
gosql "database/sql"
1010
"fmt"
11+
"reflect"
1112
"regexp"
1213
"strings"
1314
"sync/atomic"
@@ -1298,7 +1299,8 @@ func (this *Applier) updateModifiesUniqueKeyColumns(dmlEvent *binlog.BinlogDMLEv
12981299
tableOrdinal := this.migrationContext.OriginalTableColumns.Ordinals[column.Name]
12991300
whereColumnValue := dmlEvent.WhereColumnValues.AbstractValues()[tableOrdinal]
13001301
newColumnValue := dmlEvent.NewColumnValues.AbstractValues()[tableOrdinal]
1301-
if newColumnValue != whereColumnValue {
1302+
1303+
if !reflect.DeepEqual(whereColumnValue, newColumnValue) {
13021304
return column.Name, true
13031305
}
13041306
}

go/logic/applier_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ func TestApplierGenerateSqlModeQuery(t *testing.T) {
6262
}
6363

6464
func TestApplierUpdateModifiesUniqueKeyColumns(t *testing.T) {
65-
columns := sql.NewColumnList([]string{"id", "item_id"})
66-
columnValues := sql.ToColumnValues([]interface{}{123456, 42})
65+
columns := sql.NewColumnList([]string{"id", "item_id", "item_text"})
66+
columnValues := sql.ToColumnValues([]interface{}{123456, 42, []uint8{116, 101, 115, 116}})
6767

6868
migrationContext := base.NewMigrationContext()
6969
migrationContext.OriginalTableColumns = columns

localtests/sysbench/create.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* This table will get created by `sysbench prepare` */
2+
/*
3+
CREATE TABLE `sbtest1` (
4+
`id` int NOT NULL AUTO_INCREMENT,
5+
`k` int NOT NULL DEFAULT '0',
6+
`c` char(120) NOT NULL DEFAULT '',
7+
`pad` char(60) NOT NULL DEFAULT '',
8+
PRIMARY KEY (`id`),
9+
KEY `k_1` (`k`)
10+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
11+
*/
12+
13+
DROP TABLE IF EXISTS `sbtest1`;

0 commit comments

Comments
 (0)