-
Notifications
You must be signed in to change notification settings - Fork 188
Conversation
/run-all-tests |
2 similar comments
/run-all-tests |
/run-all-tests |
5b2d3e2
to
a0ad3d3
Compare
/run-all-tests |
2 similar comments
/run-all-tests |
/run-all-tests |
a2cb07a
to
837e0a4
Compare
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #236 +/- ##
===============================================
+ Coverage 58.6197% 59.8148% +1.195%
===============================================
Files 125 128 +3
Lines 15360 14366 -994
===============================================
- Hits 9004 8593 -411
+ Misses 5468 4924 -544
+ Partials 888 849 -39 |
/run-all-tests |
pkg/utils/db.go
Outdated
func (conn *BaseConn) NormalRetryOperation(ctx *tcontext.Context, operateFn func(*tcontext.Context, int) (interface{}, error), retryFn func(int, error) bool) (interface{}, error) { | ||
var err error | ||
var ret interface{} | ||
for i := 0; i < 100; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't use hard code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just let retryFn
to control when to exit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retryFn
may also need a tcontext
argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we sleep a duration?
pkg/utils/db.go
Outdated
} | ||
|
||
// InfinityRetryOperation retry operation until succeed | ||
func (conn *BaseConn) InfinityRetryOperation(operateFn func() (interface{}, error), retryFn func(error) bool) (interface{}, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do operateFn
and retryFn
need tcontext
argument?
pkg/utils/db.go
Outdated
|
||
// QuerySQL query sql | ||
func (conn *BaseConn) QuerySQL(tctx *tcontext.Context, query string) (*sql.Rows, error) { | ||
if conn == nil || conn.DB == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also check it in NormalRetryOperation
and InfinityRetryOperation
?
pkg/utils/db.go
Outdated
tctx.L().Error("rollback failed", zap.String("Query", sqls[i].Query), zap.Reflect("argument", sqls[i].Args), log.ShortError(rerr)) | ||
} | ||
// we should return the exec err, instead of the rollback rerr. | ||
return i, errors.Trace(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use the new error system in #216?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR need rebase master after #216 merged
"github.com/pingcap/dm/dm/config" | ||
tcontext "github.com/pingcap/dm/pkg/context" | ||
"github.com/pingcap/dm/pkg/log" | ||
"github.com/pingcap/dm/pkg/utils" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We divide the import package path into three sections
- built-in packages
- dm packages
- other packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
syncer/relay.go
Outdated
@@ -60,7 +60,7 @@ func (s *Syncer) setInitActiveRelayLog() error { | |||
} | |||
} else { | |||
// start from dumper or loader, get current pos from master | |||
pos, _, err = utils.GetMasterStatus(s.fromDB.db, s.cfg.Flavor) | |||
pos, _, err = utils.GetMasterStatus(s.fromDB.baseConn.DB, s.cfg.Flavor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap a function to make it like s.fromDB.GetMasterStatus
?
loader/db.go
Outdated
func (conn *Conn) executeSQL2(ctx *tcontext.Context, stmt string, maxRetry int, args ...interface{}) error { | ||
if conn == nil || conn.db == nil { | ||
return errors.NotValidf("database connection") | ||
func (conn *Conn) executeSQL(ctx *tcontext.Context, ddl bool, queries []string, args ...[]interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we replace ddl bool
argument by other argument like retryFn
?
how to reset all connections in one unit to handle error |
pkg/utils/db.go
Outdated
} | ||
|
||
// InfinityRetryOperation retry operation until succeed | ||
func (conn *BaseConn) InfinityRetryOperation(operateFn func() (interface{}, error), retryFn func(error) bool) (interface{}, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems this function has no relationship with BaseConn
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, its useless, removed already
one important question: under what circumstances we will receive an invalid connection error?you can learn from code of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM.
also see #236 (comment) again.
how about adding slow log ( |
you mean log as same as loader/db.go such like |
YES, it is. |
ok, fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* syncer db conn * loader db refine * remove useless code * add db retry policy * remove syncer max retry config * add normal retry policy * update retry strategy * add context for retry * update to terror * add invalid strategy * update retry invalid connection * update retry strategy * add retry strategy comment * add reset connection logic * use same baseConn in Conns * udpate syncer dbs * unify query in log * share same *DB by all conns * split load execute sql with different retryFn * unify retry logic to pkg * put retry error together * unify syncer conn helper function * update retry logic and some tests error formats * add baseConn test * make baseconn a pkg * abstract retry strategy * add querySQL args * add whiteList error retry logic * unify retry error in syncer/loader * keep max-retry in syncerConifg
What problem does this PR solve?
What is changed and how it works?
Check List
Tests