Skip to content

Commit 8db0f58

Browse files
authored
Merge pull request #87 from postgrespro/vacuum_fix
Don't wait for concurrent vacuums
2 parents fe659b0 + 8e50927 commit 8db0f58

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

bin/pg_repack.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const char *PROGRAM_VERSION = "unknown";
6666
* https://github.com/reorg/pg_repack/issues/1
6767
* d. open transactions/locks existing on other databases than the actual
6868
* processing relation (except for locks on shared objects)
69+
* e. VACUUMs which are always executed outside transaction blocks.
6970
*
7071
* Note, there is some redundancy in how the filtering is done (e.g. excluding
7172
* based on pg_backend_pid() and application_name), but that shouldn't hurt
@@ -84,6 +85,8 @@ const char *PROGRAM_VERSION = "unknown";
8485
" AND l.pid NOT IN (pg_backend_pid(), $1) " \
8586
" AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0') " \
8687
" AND (a.application_name IS NULL OR a.application_name <> $2)" \
88+
" AND a.query !~* E'^\\\\s*vacuum\\\\s+' " \
89+
" AND a.query !~ E'^autovacuum: ' " \
8790
" AND ((d.datname IS NULL OR d.datname = current_database()) OR l.database = 0)"
8891

8992
#define SQL_XID_SNAPSHOT_90000 \
@@ -97,6 +100,8 @@ const char *PROGRAM_VERSION = "unknown";
97100
" AND l.pid NOT IN (pg_backend_pid(), $1) " \
98101
" AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0') " \
99102
" AND (a.application_name IS NULL OR a.application_name <> $2)" \
103+
" AND a.query !~* E'^\\\\s*vacuum\\\\s+' " \
104+
" AND a.query !~ E'^autovacuum: ' " \
100105
" AND ((d.datname IS NULL OR d.datname = current_database()) OR l.database = 0)"
101106

102107
/* application_name is not available before 9.0. The last clause of
@@ -111,6 +116,8 @@ const char *PROGRAM_VERSION = "unknown";
111116
" ON a.datid = d.oid " \
112117
" WHERE l.locktype = 'virtualxid' AND l.pid NOT IN (pg_backend_pid(), $1)" \
113118
" AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0') " \
119+
" AND a.query !~* E'^\\\\s*vacuum\\\\s+' " \
120+
" AND a.query !~ E'^autovacuum: ' " \
114121
" AND ((d.datname IS NULL OR d.datname = current_database()) OR l.database = 0)" \
115122
" AND ($2::text IS NOT NULL)"
116123

0 commit comments

Comments
 (0)