Skip to content

Commit 192d1c1

Browse files
committed
Increase timeout for DB operations
The default one was 10s which might be not enough for long oeprations like CLONE.
1 parent 9a1eece commit 192d1c1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmd/db/db.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"database/sql"
66
"fmt"
7+
"time"
78

89
"github.com/go-sql-driver/mysql"
910
"github.com/pkg/errors"
@@ -33,8 +34,8 @@ func NewDatabase(ctx context.Context, user apiv1alpha1.SystemUser, pass, host st
3334
config.Params = map[string]string{
3435
"interpolateParams": "true",
3536
"timeout": "10s",
36-
"readTimeout": "10s",
37-
"writeTimeout": "10s",
37+
"readTimeout": "3h",
38+
"writeTimeout": "3h",
3839
"tls": "preferred",
3940
}
4041

@@ -164,7 +165,10 @@ func (d *DB) Clone(ctx context.Context, donor, user, pass string, port int32) er
164165
return errors.Wrap(err, "set clone_valid_donor_list")
165166
}
166167

167-
_, err = d.db.ExecContext(ctx, "CLONE INSTANCE FROM ?@?:? IDENTIFIED BY ?", user, donor, port, pass)
168+
cloneCtx, cancel := context.WithTimeout(context.Background(), 1200*time.Second)
169+
defer cancel()
170+
_, err = d.db.ExecContext(cloneCtx, "CLONE INSTANCE FROM ?@?:? IDENTIFIED BY ?", user, donor, port, pass)
171+
// _, err = d.db.ExecContext(ctx, "CLONE INSTANCE FROM ?@?:? IDENTIFIED BY ?", user, donor, port, pass)
168172

169173
mErr, ok := err.(*mysql.MySQLError)
170174
if !ok {

0 commit comments

Comments
 (0)