agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
[PATCH v2 2/3] Bump transaction ID limit to warn at 100M.
2+ messages / 1 participants
[nested] [flat]

* [PATCH v2 2/3] Bump transaction ID limit to warn at 100M.
@ 2025-11-14 16:28 Nathan Bossart <nathan@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Nathan Bossart @ 2025-11-14 16:28 UTC (permalink / raw)

---
 doc/src/sgml/maintenance.sgml          | 4 ++--
 src/backend/access/transam/multixact.c | 6 +++---
 src/backend/access/transam/varsup.c    | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index c8ba94303f1..c23e0a6e260 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -670,7 +670,7 @@ SELECT datname, age(datfrozenxid) FROM pg_database;
    <para>
     If for some reason autovacuum fails to clear old XIDs from a table, the
     system will begin to emit warning messages like this when the database's
-    oldest XIDs reach forty million transactions from the wraparound point:
+    oldest XIDs reach one hundred million transactions from the wraparound point:
 
 <programlisting>
 WARNING:  database "mydb" must be vacuumed within 39985967 transactions
@@ -824,7 +824,7 @@ HINT:  Execute a database-wide VACUUM in that database.
 
     <para>
      Similar to the XID case, if autovacuum fails to clear old MXIDs from a table, the
-     system will begin to emit warning messages when the database's oldest MXIDs reach forty
+     system will begin to emit warning messages when the database's oldest MXIDs reach one hundred
      million transactions from the wraparound point.  And, just as in the XID case, if these
      warnings are ignored, the system will refuse to generate new MXIDs once there are fewer
      than three million left until wraparound.
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e1ac4bf4c0b..42bce35c887 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2072,16 +2072,16 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
 		multiStopLimit -= FirstMultiXactId;
 
 	/*
-	 * We'll start complaining loudly when we get within 40M multis of data
+	 * We'll start complaining loudly when we get within 100M multis of data
 	 * loss.  This is kind of arbitrary, but if you let your gas gauge get
-	 * down to 2% of full, would you be looking for the next gas station?  We
+	 * down to 5% of full, would you be looking for the next gas station?  We
 	 * need to be fairly liberal about this number because there are lots of
 	 * scenarios where most transactions are done by automatic clients that
 	 * won't pay attention to warnings.  (No, we're not gonna make this
 	 * configurable.  If you know enough to configure it, you know enough to
 	 * not get in this kind of trouble in the first place.)
 	 */
-	multiWarnLimit = multiWrapLimit - 40000000;
+	multiWarnLimit = multiWrapLimit - 100000000;
 	if (multiWarnLimit < FirstMultiXactId)
 		multiWarnLimit -= FirstMultiXactId;
 
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 962396bae10..5585381bc8c 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -411,16 +411,16 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
 		xidStopLimit -= FirstNormalTransactionId;
 
 	/*
-	 * We'll start complaining loudly when we get within 40M transactions of
+	 * We'll start complaining loudly when we get within 100M transactions of
 	 * data loss.  This is kind of arbitrary, but if you let your gas gauge
-	 * get down to 2% of full, would you be looking for the next gas station?
+	 * get down to 5% of full, would you be looking for the next gas station?
 	 * We need to be fairly liberal about this number because there are lots
 	 * of scenarios where most transactions are done by automatic clients that
 	 * won't pay attention to warnings.  (No, we're not gonna make this
 	 * configurable.  If you know enough to configure it, you know enough to
 	 * not get in this kind of trouble in the first place.)
 	 */
-	xidWarnLimit = xidWrapLimit - 40000000;
+	xidWarnLimit = xidWrapLimit - 100000000;
 	if (xidWarnLimit < FirstNormalTransactionId)
 		xidWarnLimit -= FirstNormalTransactionId;
 
-- 
2.39.5 (Apple Git-154)


--ChIdkGVrtcKYZbRk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v2-0003-Perodically-emit-server-logs-when-fewer-than-500M.patch



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* [PATCH v1 1/1] Add an assertion that you don't palloc in a signal handler.
@ 2026-02-17 22:24 Nathan Bossart <nathan@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Nathan Bossart @ 2026-02-17 22:24 UTC (permalink / raw)

---
 src/backend/utils/mmgr/mcxt.c |  9 +++++++++
 src/include/miscadmin.h       |  3 +++
 src/port/pqsignal.c           | 10 ++++++++++
 3 files changed, 22 insertions(+)

diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 073bdb35d2a..4d79359b0b9 100644
--- a/src/backend/utils/mmgr/mcxt.c
+++ b/src/backend/utils/mmgr/mcxt.c
@@ -1235,6 +1235,7 @@ MemoryContextAlloc(MemoryContext context, Size size)
 
 	Assert(MemoryContextIsValid(context));
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	context->isReset = false;
 
@@ -1269,6 +1270,7 @@ MemoryContextAllocZero(MemoryContext context, Size size)
 
 	Assert(MemoryContextIsValid(context));
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	context->isReset = false;
 
@@ -1292,6 +1294,7 @@ MemoryContextAllocExtended(MemoryContext context, Size size, int flags)
 
 	Assert(MemoryContextIsValid(context));
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	if (!((flags & MCXT_ALLOC_HUGE) != 0 ? AllocHugeSizeIsValid(size) :
 		  AllocSizeIsValid(size)))
@@ -1392,6 +1395,7 @@ palloc(Size size)
 
 	Assert(MemoryContextIsValid(context));
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	context->isReset = false;
 
@@ -1422,6 +1426,7 @@ palloc0(Size size)
 
 	Assert(MemoryContextIsValid(context));
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	context->isReset = false;
 
@@ -1444,6 +1449,7 @@ palloc_extended(Size size, int flags)
 
 	Assert(MemoryContextIsValid(context));
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	context->isReset = false;
 
@@ -1637,6 +1643,7 @@ repalloc(void *pointer, Size size)
 	void	   *ret;
 
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	/* isReset must be false already */
 	Assert(!context->isReset);
@@ -1672,6 +1679,7 @@ repalloc_extended(void *pointer, Size size, int flags)
 	void	   *ret;
 
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	/* isReset must be false already */
 	Assert(!context->isReset);
@@ -1728,6 +1736,7 @@ MemoryContextAllocHuge(MemoryContext context, Size size)
 
 	Assert(MemoryContextIsValid(context));
 	AssertNotInCriticalSection(context);
+	Assert(!InSignalHandler);
 
 	context->isReset = false;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index f16f35659b9..a1c89147586 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -155,6 +155,9 @@ do { \
 	CritSectionCount--; \
 } while(0)
 
+/* in port/pqsignal.c */
+extern PGDLLIMPORT volatile sig_atomic_t InSignalHandler;
+
 
 /*****************************************************************************
  *	  globals.h --															 *
diff --git a/src/port/pqsignal.c b/src/port/pqsignal.c
index fbdf9341c2f..6e036975b3c 100644
--- a/src/port/pqsignal.c
+++ b/src/port/pqsignal.c
@@ -71,6 +71,10 @@ StaticAssertDecl(SIGALRM < PG_NSIG, "SIGALRM >= PG_NSIG");
 
 static volatile pqsigfunc pqsignal_handlers[PG_NSIG];
 
+#ifndef FRONTEND
+volatile sig_atomic_t InSignalHandler = false;
+#endif
+
 /*
  * Except when called with SIG_IGN or SIG_DFL, pqsignal() sets up this function
  * as the handler for all signals.  This wrapper handler function checks that
@@ -99,6 +103,8 @@ wrapper_handler(SIGNAL_ARGS)
 	Assert(MyProcPid);
 	Assert(MyProcPid != PostmasterPid || !IsUnderPostmaster);
 
+	InSignalHandler = true;
+
 	if (unlikely(MyProcPid != (int) getpid()))
 	{
 		pqsignal(postgres_signal_arg, SIG_DFL);
@@ -109,6 +115,10 @@ wrapper_handler(SIGNAL_ARGS)
 
 	(*pqsignal_handlers[postgres_signal_arg]) (postgres_signal_arg);
 
+#ifndef FRONTEND
+	InSignalHandler = false;
+#endif
+
 	errno = save_errno;
 }
 
-- 
2.50.1 (Apple Git-155)


--pa4wzpETADBTomYH--





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-02-17 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-11-14 16:28 [PATCH v2 2/3] Bump transaction ID limit to warn at 100M. Nathan Bossart <nathan@postgresql.org>
2026-02-17 22:24 [PATCH v1 1/1] Add an assertion that you don't palloc in a signal handler. Nathan Bossart <nathan@postgresql.org>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox