Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
chaos: fix diffIncrData has no effect (#1350)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD authored Dec 21, 2020
1 parent e5c5de8 commit 0c56124
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions chaos/cases/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ func (c *config) parse(args []string) error {

func (c *config) adjust() {
// `go-sqlsmith` may generate ZERO time data, so we simply clear `sql_mode` now.
c.Source1.Session = map[string]string{"sql_mode": ""}
c.Source2.Session = map[string]string{"sql_mode": ""}
c.Target.Session = map[string]string{"sql_mode": ""}
// mysql:5.7 `explicit_defaults_for_timestamp`: OFF
// tidb `explicit_defaults_for_timestamp`: ON
// `ALTER TABLE .* ADD COLUMN (.* TIMESTAMP)` will have different default value
c.Source1.Session = map[string]string{"sql_mode": "", "explicit_defaults_for_timestamp": "on"}
c.Source2.Session = map[string]string{"sql_mode": "", "explicit_defaults_for_timestamp": "on"}

c.Source1.Adjust()
c.Source2.Adjust()
Expand Down
1 change: 1 addition & 0 deletions chaos/cases/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func diffDataLoop(ctx context.Context, count int, interval time.Duration, schema
if err == nil {
return nil
}
log.L().Warn("diff data error", zap.Int("count", i+1), log.ShortError(err))
}
}
return err
Expand Down
10 changes: 5 additions & 5 deletions chaos/cases/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
const (
tableCount = 10 // tables count in schema.
fullInsertCount = 100 // `INSERT INTO` count (not rows count) for each table in full stage.
diffCount = 10 // diff data check count
diffCount = 20 // diff data check count
diffInterval = 10 * time.Second // diff data check interval
incrRoundTime = 20 * time.Second // time to generate incremental data in one round
)
Expand Down Expand Up @@ -74,7 +74,7 @@ func newTask(ctx context.Context, cli pb.MasterClient, taskFile string, schema s
var (
sourceDBs = make([]*conn.BaseDB, 0, len(taskCfg.MySQLInstances))
sourceConns = make([]*dbConn, 0, len(taskCfg.MySQLInstances))
results = make(results, 0, len(taskCfg.MySQLInstances))
res = make(results, 0, len(taskCfg.MySQLInstances))
)
for i := range taskCfg.MySQLInstances { // only use necessary part of sources.
cfg := sourcesCfg[i]
Expand All @@ -88,7 +88,7 @@ func newTask(ctx context.Context, cli pb.MasterClient, taskFile string, schema s
}
sourceDBs = append(sourceDBs, db)
sourceConns = append(sourceConns, conn)
results = append(results, singleResult{})
res = append(res, singleResult{})
}

targetDB, err := conn.DefaultDBProvider.Apply(targetCfg)
Expand All @@ -112,7 +112,7 @@ func newTask(ctx context.Context, cli pb.MasterClient, taskFile string, schema s
schema: schema,
tables: make([]string, 0),
taskCfg: taskCfg,
results: results,
results: res,
}
t.ss.SetDB(schema)
return t, nil
Expand Down Expand Up @@ -278,7 +278,7 @@ func (t *task) incrLoop() error {
}

// diff data
err = t.diffIncrData(ctx2)
err = t.diffIncrData(t.ctx)
if err != nil {
cancel2()
return err
Expand Down

0 comments on commit 0c56124

Please sign in to comment.