Skip to content

Commit c4d360d

Browse files
committed
Use just one database connection in the "tablespace" test.
On Windows, DROP TABLESPACE has a race condition when run concurrently with other processes having opened files in the tablespace. This led to a rare failure on buildfarm member frogmouth. Back-patch to 9.4, where the reconnection was introduced.
1 parent 8fb4218 commit c4d360d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/backend/commands/tablespace.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,13 @@ DropTableSpace(DropTableSpaceStmt *stmt)
491491
* but we can't tell them apart from important data files that we
492492
* mustn't delete. So instead, we force a checkpoint which will clean
493493
* out any lingering files, and try again.
494+
*
495+
* XXX On Windows, an unlinked file persists in the directory listing
496+
* until no process retains an open handle for the file. The DDL
497+
* commands that schedule files for unlink send invalidation messages
498+
* directing other PostgreSQL processes to close the files. DROP
499+
* TABLESPACE should not give up on the tablespace becoming empty
500+
* until all relevant invalidation processing is complete.
494501
*/
495502
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT);
496503
if (!destroy_tablespace_directories(tablespaceoid, false))

src/test/regress/input/tablespace.source

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ ALTER TABLESPACE testspace OWNER TO tablespace_testuser1;
7171

7272
SET SESSION ROLE tablespace_testuser2;
7373
CREATE TABLE tablespace_table (i int) TABLESPACE testspace; -- fail
74-
75-
\c -
74+
RESET ROLE;
7675

7776
ALTER TABLESPACE testspace RENAME TO testspace_renamed;
7877

src/test/regress/output/tablespace.source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ ALTER TABLESPACE testspace OWNER TO tablespace_testuser1;
9191
SET SESSION ROLE tablespace_testuser2;
9292
CREATE TABLE tablespace_table (i int) TABLESPACE testspace; -- fail
9393
ERROR: permission denied for tablespace testspace
94-
\c -
94+
RESET ROLE;
9595
ALTER TABLESPACE testspace RENAME TO testspace_renamed;
9696
ALTER TABLE ALL IN TABLESPACE testspace_renamed SET TABLESPACE pg_default;
9797
ALTER INDEX ALL IN TABLESPACE testspace_renamed SET TABLESPACE pg_default;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy