Skip to content

Commit c97d3a4

Browse files
Merge pull request #1129 from planetscale/db-create-timeout
Increase db create --wait timeout
2 parents 636f65a + b122846 commit c97d3a4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

internal/cmd/database/create.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,15 @@ func parseDatabaseEngine(engine string) (ps.DatabaseEngine, error) {
117117
}
118118

119119
func waitUntilReady(ctx context.Context, client *ps.Client, printer *printer.Printer, debug bool, getReq *ps.GetDatabaseRequest) error {
120-
ctx, cancel := context.WithTimeout(ctx, 3*time.Minute)
120+
ctx, cancel := context.WithTimeout(ctx, 10*time.Minute)
121121
defer cancel()
122122

123-
ticker := time.NewTicker(time.Second)
123+
startTime := time.Now()
124+
var ticker *time.Ticker
125+
126+
// Start with 5-second interval for the first minute
127+
ticker = time.NewTicker(5 * time.Second)
128+
defer ticker.Stop()
124129

125130
for {
126131
select {
@@ -138,6 +143,13 @@ func waitUntilReady(ctx context.Context, client *ps.Client, printer *printer.Pri
138143
if resp.State == "ready" {
139144
return nil
140145
}
146+
147+
elapsed := time.Since(startTime)
148+
if elapsed > time.Minute {
149+
// Switch to 10-second interval after 1 minute
150+
ticker.Stop()
151+
ticker = time.NewTicker(10 * time.Second)
152+
}
141153
}
142154
}
143155
}

0 commit comments

Comments
 (0)