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

Mysqlworker logging changes #352

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions worker/mysqlworker/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,22 @@ func (adapter *mysqlAdapter) InitDB() (*sql.DB, error) {
}
db.Close()
}
attempt = attempt + 1
// Adding additional logging for error scenario
if err != nil {
if logger.GetLogger().V(logger.Warning) {
logger.GetLogger().Log(logger.Warning, fmt.Sprintf("Failed to connect datasource=%s, retry-attempt=%d and error=%v", curDs, attempt, err.Error()))
}
}
// read only connection
if logger.GetLogger().V(logger.Warning) {
logger.GetLogger().Log(logger.Warning, "recycling, got read-only conn " /*+curDs*/ +fmt.Sprintf("retry-attempt=%d", attempt-1))
logger.GetLogger().Log(logger.Warning, "recycling, got read-only conn " /*+curDs*/ +fmt.Sprintf("retry-attempt=%d", attempt))
}

evt := cal.NewCalEvent("INITDB", "RECYCLE_ON_READ_ONLY", cal.TransWarning, fmt.Sprintf("retry-attempt=%d", attempt-1))
evt := cal.NewCalEvent("INITDB", "RECYCLE_ON_READ_ONLY", cal.TransWarning, fmt.Sprintf("retry-attempt=%d", attempt))
evt.SetStatus(cal.TransError)
evt.Completed()

attempt = attempt + 1
pwdStr := fmt.Sprintf("password%d", attempt)
pass = os.Getenv(pwdStr)
}
Expand All @@ -118,7 +124,7 @@ func (adapter *mysqlAdapter) InitDB() (*sql.DB, error) {
}
calTrans.Completed()
if err != nil {
spread := 11 * time.Second + time.Duration(rand.Intn(11000999888)/*ns*/)
spread := 11*time.Second + time.Duration(rand.Intn(11000999888) /*ns*/)
logger.GetLogger().Log(logger.Warning, "onErr sleeping "+spread.String())
time.Sleep(spread)
}
Expand Down