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

Commitdef30e8

Browse files
committed
Don't try to fetch database name when SetTransactionIdLimit() is executed
outside a transaction.This repairs brain fade in my patch of 2009-08-30: the reason we had beenstoring oldest-database name, not OID, in ShmemVariableCache was of courseto avoid having to do a catalog lookup at times when it might be unsafe.This error explains why Aleksandr Dushein is having trouble getting out ofan XID wraparound state in bug #5718, though not how he got into that statein the first place. I suspect pg_upgrade is at fault there.
1 parent17a1666 commitdef30e8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

‎src/backend/access/transam/varsup.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include"access/clog.h"
1717
#include"access/subtrans.h"
1818
#include"access/transam.h"
19+
#include"access/xact.h"
1920
#include"commands/dbcommands.h"
2021
#include"miscadmin.h"
2122
#include"postmaster/autovacuum.h"
@@ -346,13 +347,22 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
346347
/* Give an immediate warning if past the wrap warn point */
347348
if (TransactionIdFollowsOrEquals(curXid,xidWarnLimit)&& !InRecovery)
348349
{
349-
char*oldest_datname=get_database_name(oldest_datoid);
350+
char*oldest_datname;
350351

351352
/*
352-
* Note: it's possible that get_database_name fails and returns NULL,
353-
* for example because the database just got dropped. We'll still
354-
* warn, even though the warning might now be unnecessary.
353+
* We can be called when not inside a transaction, for example
354+
* during StartupXLOG(). In such a case we cannot do database
355+
* access, so we must just report the oldest DB's OID.
356+
*
357+
* Note: it's also possible that get_database_name fails and returns
358+
* NULL, for example because the database just got dropped. We'll
359+
* still warn, even though the warning might now be unnecessary.
355360
*/
361+
if (IsTransactionState())
362+
oldest_datname=get_database_name(oldest_datoid);
363+
else
364+
oldest_datname=NULL;
365+
356366
if (oldest_datname)
357367
ereport(WARNING,
358368
(errmsg("database \"%s\" must be vacuumed within %u transactions",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp