Skip to content

Commit 2958a67

Browse files
Extend near-wraparound hints to include replication slots
Author: Feike Steenbergen Reviewed-by: Michael Paquier
1 parent 0aa1d48 commit 2958a67

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

doc/src/sgml/logicaldecoding.sgml

+5-3
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,18 @@ $ pg_recvlogical -d postgres --slot test --drop-slot
248248
may consume changes from a slot at any given time.
249249
</para>
250250

251-
<note>
251+
<caution>
252252
<para>
253253
Replication slots persist across crashes and know nothing about the state
254254
of their consumer(s). They will prevent removal of required resources
255255
even when there is no connection using them. This consumes storage
256256
because neither required WAL nor required rows from the system catalogs
257257
can be removed by <command>VACUUM</command> as long as they are required by a replication
258-
slot. So if a slot is no longer required it should be dropped.
258+
slot. In extreme cases this could cause the database to shut down to prevent
259+
transaction ID wraparound (see <xref linkend="vacuum-for-wraparound"/>).
260+
So if a slot is no longer required it should be dropped.
259261
</para>
260-
</note>
262+
</caution>
261263
</sect2>
262264

263265
<sect2>

src/backend/access/transam/multixact.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1000,14 +1000,14 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
10001000
errmsg("database is not accepting commands that generate new MultiXactIds to avoid wraparound data loss in database \"%s\"",
10011001
oldest_datname),
10021002
errhint("Execute a database-wide VACUUM in that database.\n"
1003-
"You might also need to commit or roll back old prepared transactions.")));
1003+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
10041004
else
10051005
ereport(ERROR,
10061006
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
10071007
errmsg("database is not accepting commands that generate new MultiXactIds to avoid wraparound data loss in database with OID %u",
10081008
oldest_datoid),
10091009
errhint("Execute a database-wide VACUUM in that database.\n"
1010-
"You might also need to commit or roll back old prepared transactions.")));
1010+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
10111011
}
10121012

10131013
/*
@@ -1031,7 +1031,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
10311031
oldest_datname,
10321032
multiWrapLimit - result),
10331033
errhint("Execute a database-wide VACUUM in that database.\n"
1034-
"You might also need to commit or roll back old prepared transactions.")));
1034+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
10351035
else
10361036
ereport(WARNING,
10371037
(errmsg_plural("database with OID %u must be vacuumed before %u more MultiXactId is used",
@@ -1040,7 +1040,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
10401040
oldest_datoid,
10411041
multiWrapLimit - result),
10421042
errhint("Execute a database-wide VACUUM in that database.\n"
1043-
"You might also need to commit or roll back old prepared transactions.")));
1043+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
10441044
}
10451045

10461046
/* Re-acquire lock and start over */
@@ -2321,7 +2321,7 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid,
23212321
oldest_datname,
23222322
multiWrapLimit - curMulti),
23232323
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
2324-
"You might also need to commit or roll back old prepared transactions.")));
2324+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
23252325
else
23262326
ereport(WARNING,
23272327
(errmsg_plural("database with OID %u must be vacuumed before %u more MultiXactId is used",
@@ -2330,7 +2330,7 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid,
23302330
oldest_datoid,
23312331
multiWrapLimit - curMulti),
23322332
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
2333-
"You might also need to commit or roll back old prepared transactions.")));
2333+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
23342334
}
23352335
}
23362336

src/backend/access/transam/varsup.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ GetNewTransactionId(bool isSubXact)
124124
errmsg("database is not accepting commands to avoid wraparound data loss in database \"%s\"",
125125
oldest_datname),
126126
errhint("Stop the postmaster and vacuum that database in single-user mode.\n"
127-
"You might also need to commit or roll back old prepared transactions.")));
127+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
128128
else
129129
ereport(ERROR,
130130
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
131131
errmsg("database is not accepting commands to avoid wraparound data loss in database with OID %u",
132132
oldest_datoid),
133133
errhint("Stop the postmaster and vacuum that database in single-user mode.\n"
134-
"You might also need to commit or roll back old prepared transactions.")));
134+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
135135
}
136136
else if (TransactionIdFollowsOrEquals(xid, xidWarnLimit))
137137
{
@@ -144,14 +144,14 @@ GetNewTransactionId(bool isSubXact)
144144
oldest_datname,
145145
xidWrapLimit - xid),
146146
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
147-
"You might also need to commit or roll back old prepared transactions.")));
147+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
148148
else
149149
ereport(WARNING,
150150
(errmsg("database with OID %u must be vacuumed within %u transactions",
151151
oldest_datoid,
152152
xidWrapLimit - xid),
153153
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
154-
"You might also need to commit or roll back old prepared transactions.")));
154+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
155155
}
156156

157157
/* Re-acquire lock and start over */
@@ -403,14 +403,14 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
403403
oldest_datname,
404404
xidWrapLimit - curXid),
405405
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
406-
"You might also need to commit or roll back old prepared transactions.")));
406+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
407407
else
408408
ereport(WARNING,
409409
(errmsg("database with OID %u must be vacuumed within %u transactions",
410410
oldest_datoid,
411411
xidWrapLimit - curXid),
412412
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
413-
"You might also need to commit or roll back old prepared transactions.")));
413+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
414414
}
415415
}
416416

src/backend/commands/vacuum.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ vacuum_set_xid_limits(Relation rel,
655655
{
656656
ereport(WARNING,
657657
(errmsg("oldest xmin is far in the past"),
658-
errhint("Close open transactions soon to avoid wraparound problems.")));
658+
errhint("Close open transactions soon to avoid wraparound problems.\n"
659+
"You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
659660
limit = *oldestXmin;
660661
}
661662

0 commit comments

Comments
 (0)