added 'table is locked' error msg retry check
This commit is contained in:
parent
4adc4b28d2
commit
e53c30ca4d
|
@ -46,14 +46,16 @@ func baseLockRetry(op func(attempt int) error, maxRetries int) error {
|
||||||
Retry:
|
Retry:
|
||||||
err := op(attempt)
|
err := op(attempt)
|
||||||
|
|
||||||
if err != nil &&
|
if err != nil && attempt <= maxRetries {
|
||||||
attempt <= maxRetries &&
|
errStr := err.Error()
|
||||||
// we are checking the plain error text to handle both cgo and noncgo errors
|
// we are checking the error against the plain error texts since the codes could vary between drivers
|
||||||
strings.Contains(err.Error(), "database is locked") {
|
if strings.Contains(errStr, "database is locked") ||
|
||||||
// wait and retry
|
strings.Contains(errStr, "table is locked") {
|
||||||
time.Sleep(getDefaultRetryInterval(attempt))
|
// wait and retry
|
||||||
attempt++
|
time.Sleep(getDefaultRetryInterval(attempt))
|
||||||
goto Retry
|
attempt++
|
||||||
|
goto Retry
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -33,6 +33,7 @@ func TestBaseLockRetry(t *testing.T) {
|
||||||
{nil, 3, 1},
|
{nil, 3, 1},
|
||||||
{errors.New("test"), 3, 1},
|
{errors.New("test"), 3, 1},
|
||||||
{errors.New("database is locked"), 3, 3},
|
{errors.New("database is locked"), 3, 3},
|
||||||
|
{errors.New("table is locked"), 3, 3},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, s := range scenarios {
|
for i, s := range scenarios {
|
||||||
|
|
Loading…
Reference in New Issue