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

Commit794e3e8

Browse files
committed
Force VACUUM to recalculate oldestXmin even when we haven't changed our
own database's datfrozenxid, if the current value is old enough to beforcing autovacuums or warning messages. This ensures that a bogusvalue is replaced as soon as possible. Per a comment from Heikki.
1 parent14f445f commit794e3e8

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.85 2009/08/31 02:23:21 tgl Exp $
9+
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.86 2009/09/01 04:46:49 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -372,32 +372,41 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
372372

373373

374374
/*
375-
*TransactionIdLimitIsValid --is thesharedXID wrap-limit datasane?
375+
*ForceTransactionIdLimitUpdate --does the XID wrap-limit dataneed updating?
376376
*
377377
* We primarily check whether oldestXidDB is valid. The cases we have in
378378
* mind are that that database was dropped, or the field was reset to zero
379379
* by pg_resetxlog. In either case we should force recalculation of the
380-
* wrap limit. In future we might add some more sanity checks here.
380+
* wrap limit. Also do it if oldestXid is old enough to be forcing
381+
* autovacuums or other actions; this ensures we update our state as soon
382+
* as possible once extra overhead is being incurred.
381383
*/
382384
bool
383-
TransactionIdLimitIsValid(void)
385+
ForceTransactionIdLimitUpdate(void)
384386
{
387+
TransactionIdnextXid;
388+
TransactionIdxidVacLimit;
385389
TransactionIdoldestXid;
386390
OidoldestXidDB;
387391

388392
/* Locking is probably not really necessary, but let's be careful */
389393
LWLockAcquire(XidGenLock,LW_SHARED);
394+
nextXid=ShmemVariableCache->nextXid;
395+
xidVacLimit=ShmemVariableCache->xidVacLimit;
390396
oldestXid=ShmemVariableCache->oldestXid;
391397
oldestXidDB=ShmemVariableCache->oldestXidDB;
392398
LWLockRelease(XidGenLock);
393399

394400
if (!TransactionIdIsNormal(oldestXid))
395-
return false;/* shouldn't happen, but just in case */
401+
return true;/* shouldn't happen, but just in case */
402+
if (TransactionIdFollowsOrEquals(nextXid,xidVacLimit)&&
403+
TransactionIdIsValid(xidVacLimit))
404+
return true;/* past VacLimit, don't delay updating */
396405
if (!SearchSysCacheExists(DATABASEOID,
397406
ObjectIdGetDatum(oldestXidDB),
398407
0,0,0))
399-
returnfalse;/* could happen, percomment above */
400-
returntrue;
408+
returntrue;/* could happen, percomments above */
409+
returnfalse;
401410
}
402411

403412

‎src/backend/commands/vacuum.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.392 2009/09/0102:54:51 alvherre Exp $
16+
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.393 2009/09/0104:46:49 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -893,9 +893,10 @@ vac_update_datfrozenxid(void)
893893

894894
/*
895895
* If we were able to advance datfrozenxid, see if we can truncate pg_clog.
896-
* Also do it if the shared XID-wrap-limit info is stale.
896+
* Also do it if the shared XID-wrap-limit info is stale, since this
897+
* action will update that too.
897898
*/
898-
if (dirty||!TransactionIdLimitIsValid())
899+
if (dirty||ForceTransactionIdLimitUpdate())
899900
vac_truncate_clog(newFrozenXid);
900901
}
901902

‎src/include/access/transam.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/transam.h,v 1.69 2009/08/31 02:23:23 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/access/transam.h,v 1.70 2009/09/01 04:46:49 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -156,7 +156,7 @@ extern TransactionId GetNewTransactionId(bool isSubXact);
156156
externTransactionIdReadNewTransactionId(void);
157157
externvoidSetTransactionIdLimit(TransactionIdoldest_datfrozenxid,
158158
Oidoldest_datoid);
159-
externboolTransactionIdLimitIsValid(void);
159+
externboolForceTransactionIdLimitUpdate(void);
160160
externOidGetNewObjectId(void);
161161

162162
#endif/* TRAMSAM_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp