Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e8ff44

Browse files
committed
fix: ensure embedded-postgres state is wiped between retries
Retries were previously added when starting embedded postgres to mitigate portallocation conflicts (we can't use an ephemeral port). Retries alone seeminglydid not fix the test flakes. A new failure mode appeared on the retries: timingout connecting to the database.When a port discovery error occurrs, embedded-postgres does not create thedatabase. If the data directory exists on the next attempt, embedded-postgreswill assume the database has already been created. This seems to cause thetimeout error. Wipe all state between retries to ensure attempts execute thesame logic that creates the database.
1 parenta272843 commit9e8ff44

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎cli/server.go‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,6 +2158,14 @@ func startBuiltinPostgres(ctx context.Context, cfg config.Root, logger slog.Logg
21582158

21592159
varstartErrerror
21602160
forattempt:=0;attempt<maxAttempts;attempt++ {
2161+
ifretryPortDiscovery&&attempt>0 {
2162+
// Clean up the data and runtime directories and the port file from the
2163+
// previous failed attempt to ensure a clean slate for the next attempt.
2164+
_=os.RemoveAll(filepath.Join(cfg.PostgresPath(),"data"))
2165+
_=os.RemoveAll(filepath.Join(cfg.PostgresPath(),"runtime"))
2166+
_=cfg.PostgresPort().Delete()
2167+
}
2168+
21612169
// Ensure a password and port have been generated.
21622170
connectionURL,err:=embeddedPostgresURL(cfg)
21632171
iferr!=nil {
@@ -2204,11 +2212,6 @@ func startBuiltinPostgres(ctx context.Context, cfg config.Root, logger slog.Logg
22042212
slog.F("port",pgPort),
22052213
slog.Error(startErr),
22062214
)
2207-
2208-
ifretryPortDiscovery {
2209-
// Since a retry is needed, we wipe the port stored here at the beginning of the loop.
2210-
_=cfg.PostgresPort().Delete()
2211-
}
22122215
}
22132216

22142217
return"",nil,xerrors.Errorf("failed to start built-in PostgreSQL after %d attempts. "+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp