mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
pgindent run on access/transam/multixact.c
This file has been patched over and over, and the differences to master caused by pgindent are annoying enough that it seems saner to make the older branches look the same. Backpatch to 9.3, which is as far back as backpatching of bugfixes is necessary.
This commit is contained in:
@@ -306,8 +306,8 @@ typedef struct mXactCacheEnt
|
|||||||
} mXactCacheEnt;
|
} mXactCacheEnt;
|
||||||
|
|
||||||
#define MAX_CACHE_ENTRIES 256
|
#define MAX_CACHE_ENTRIES 256
|
||||||
static dlist_head MXactCache = DLIST_STATIC_INIT(MXactCache);
|
static dlist_head MXactCache = DLIST_STATIC_INIT(MXactCache);
|
||||||
static int MXactCacheMembers = 0;
|
static int MXactCacheMembers = 0;
|
||||||
static MemoryContext MXactContext = NULL;
|
static MemoryContext MXactContext = NULL;
|
||||||
|
|
||||||
#ifdef MULTIXACT_DEBUG
|
#ifdef MULTIXACT_DEBUG
|
||||||
@@ -620,9 +620,9 @@ MultiXactIdSetOldestMember(void)
|
|||||||
* back. Which would be wrong.
|
* back. Which would be wrong.
|
||||||
*
|
*
|
||||||
* Note that a shared lock is sufficient, because it's enough to stop
|
* Note that a shared lock is sufficient, because it's enough to stop
|
||||||
* someone from advancing nextMXact; and nobody else could be trying to
|
* someone from advancing nextMXact; and nobody else could be trying
|
||||||
* write to our OldestMember entry, only reading (and we assume storing
|
* to write to our OldestMember entry, only reading (and we assume
|
||||||
* it is atomic.)
|
* storing it is atomic.)
|
||||||
*/
|
*/
|
||||||
LWLockAcquire(MultiXactGenLock, LW_SHARED);
|
LWLockAcquire(MultiXactGenLock, LW_SHARED);
|
||||||
|
|
||||||
@@ -970,7 +970,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
|
|||||||
*/
|
*/
|
||||||
if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit) ||
|
if (!MultiXactIdPrecedes(result, MultiXactState->multiVacLimit) ||
|
||||||
(MultiXactState->nextOffset - MultiXactState->oldestOffset
|
(MultiXactState->nextOffset - MultiXactState->oldestOffset
|
||||||
> MULTIXACT_MEMBER_SAFE_THRESHOLD))
|
> MULTIXACT_MEMBER_SAFE_THRESHOLD))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* For safety's sake, we release MultiXactGenLock while sending
|
* For safety's sake, we release MultiXactGenLock while sending
|
||||||
@@ -1025,8 +1025,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
|
|||||||
(errmsg_plural("database \"%s\" must be vacuumed before %u more MultiXactId is used",
|
(errmsg_plural("database \"%s\" must be vacuumed before %u more MultiXactId is used",
|
||||||
"database \"%s\" must be vacuumed before %u more MultiXactIds are used",
|
"database \"%s\" must be vacuumed before %u more MultiXactIds are used",
|
||||||
multiWrapLimit - result,
|
multiWrapLimit - result,
|
||||||
oldest_datname,
|
oldest_datname,
|
||||||
multiWrapLimit - result),
|
multiWrapLimit - result),
|
||||||
errhint("Execute a database-wide VACUUM in that database.\n"
|
errhint("Execute a database-wide VACUUM in that database.\n"
|
||||||
"You might also need to commit or roll back old prepared transactions.")));
|
"You might also need to commit or roll back old prepared transactions.")));
|
||||||
else
|
else
|
||||||
@@ -1034,8 +1034,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
|
|||||||
(errmsg_plural("database with OID %u must be vacuumed before %u more MultiXactId is used",
|
(errmsg_plural("database with OID %u must be vacuumed before %u more MultiXactId is used",
|
||||||
"database with OID %u must be vacuumed before %u more MultiXactIds are used",
|
"database with OID %u must be vacuumed before %u more MultiXactIds are used",
|
||||||
multiWrapLimit - result,
|
multiWrapLimit - result,
|
||||||
oldest_datoid,
|
oldest_datoid,
|
||||||
multiWrapLimit - result),
|
multiWrapLimit - result),
|
||||||
errhint("Execute a database-wide VACUUM in that database.\n"
|
errhint("Execute a database-wide VACUUM in that database.\n"
|
||||||
"You might also need to commit or roll back old prepared transactions.")));
|
"You might also need to commit or roll back old prepared transactions.")));
|
||||||
}
|
}
|
||||||
@@ -1194,14 +1194,14 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
|
|||||||
*
|
*
|
||||||
* An ID older than MultiXactState->oldestMultiXactId cannot possibly be
|
* An ID older than MultiXactState->oldestMultiXactId cannot possibly be
|
||||||
* useful; it has already been removed, or will be removed shortly, by
|
* useful; it has already been removed, or will be removed shortly, by
|
||||||
* truncation. Returning the wrong values could lead
|
* truncation. Returning the wrong values could lead to an incorrect
|
||||||
* to an incorrect visibility result. However, to support pg_upgrade we
|
* visibility result. However, to support pg_upgrade we need to allow an
|
||||||
* need to allow an empty set to be returned regardless, if the caller is
|
* empty set to be returned regardless, if the caller is willing to accept
|
||||||
* willing to accept it; the caller is expected to check that it's an
|
* it; the caller is expected to check that it's an allowed condition
|
||||||
* allowed condition (such as ensuring that the infomask bits set on the
|
* (such as ensuring that the infomask bits set on the tuple are
|
||||||
* tuple are consistent with the pg_upgrade scenario). If the caller is
|
* consistent with the pg_upgrade scenario). If the caller is expecting
|
||||||
* expecting this to be called only on recently created multis, then we
|
* this to be called only on recently created multis, then we raise an
|
||||||
* raise an error.
|
* error.
|
||||||
*
|
*
|
||||||
* Conversely, an ID >= nextMXact shouldn't ever be seen here; if it is
|
* Conversely, an ID >= nextMXact shouldn't ever be seen here; if it is
|
||||||
* seen, it implies undetected ID wraparound has occurred. This raises a
|
* seen, it implies undetected ID wraparound has occurred. This raises a
|
||||||
@@ -1383,8 +1383,8 @@ retry:
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* MultiXactHasRunningRemoteMembers
|
* MultiXactHasRunningRemoteMembers
|
||||||
* Does the given multixact have still-live members from
|
* Does the given multixact have still-live members from
|
||||||
* transactions other than our own?
|
* transactions other than our own?
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
MultiXactHasRunningRemoteMembers(MultiXactId multi)
|
MultiXactHasRunningRemoteMembers(MultiXactId multi)
|
||||||
@@ -1935,7 +1935,7 @@ MaybeExtendOffsetSlru(void)
|
|||||||
|
|
||||||
if (!SimpleLruDoesPhysicalPageExist(MultiXactOffsetCtl, pageno))
|
if (!SimpleLruDoesPhysicalPageExist(MultiXactOffsetCtl, pageno))
|
||||||
{
|
{
|
||||||
int slotno;
|
int slotno;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fortunately for us, SimpleLruWritePage is already prepared to deal
|
* Fortunately for us, SimpleLruWritePage is already prepared to deal
|
||||||
@@ -2142,11 +2142,11 @@ MultiXactSetNextMXact(MultiXactId nextMulti,
|
|||||||
* enough to contain the next value that would be created.
|
* enough to contain the next value that would be created.
|
||||||
*
|
*
|
||||||
* We need to do this pretty early during the first startup in binary
|
* We need to do this pretty early during the first startup in binary
|
||||||
* upgrade mode: before StartupMultiXact() in fact, because this routine is
|
* upgrade mode: before StartupMultiXact() in fact, because this routine
|
||||||
* called even before that by StartupXLOG(). And we can't do it earlier
|
* is called even before that by StartupXLOG(). And we can't do it
|
||||||
* than at this point, because during that first call of this routine we
|
* earlier than at this point, because during that first call of this
|
||||||
* determine the MultiXactState->nextMXact value that MaybeExtendOffsetSlru
|
* routine we determine the MultiXactState->nextMXact value that
|
||||||
* needs.
|
* MaybeExtendOffsetSlru needs.
|
||||||
*/
|
*/
|
||||||
if (IsBinaryUpgrade)
|
if (IsBinaryUpgrade)
|
||||||
MaybeExtendOffsetSlru();
|
MaybeExtendOffsetSlru();
|
||||||
@@ -2221,11 +2221,11 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the offset of the oldest multixact that might still be
|
* Determine the offset of the oldest multixact that might still be
|
||||||
* referenced. Normally, we can read the offset from the multixact itself,
|
* referenced. Normally, we can read the offset from the multixact
|
||||||
* but there's an important special case: if there are no multixacts in
|
* itself, but there's an important special case: if there are no
|
||||||
* existence at all, oldest_datminmxid obviously can't point to one. It
|
* multixacts in existence at all, oldest_datminmxid obviously can't point
|
||||||
* will instead point to the multixact ID that will be assigned the next
|
* to one. It will instead point to the multixact ID that will be
|
||||||
* time one is needed.
|
* assigned the next time one is needed.
|
||||||
*
|
*
|
||||||
* NB: oldest_dataminmxid is the oldest multixact that might still be
|
* NB: oldest_dataminmxid is the oldest multixact that might still be
|
||||||
* referenced from a table, unlike in DetermineSafeOldestOffset, where we
|
* referenced from a table, unlike in DetermineSafeOldestOffset, where we
|
||||||
@@ -2302,8 +2302,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
|
|||||||
(errmsg_plural("database \"%s\" must be vacuumed before %u more MultiXactId is used",
|
(errmsg_plural("database \"%s\" must be vacuumed before %u more MultiXactId is used",
|
||||||
"database \"%s\" must be vacuumed before %u more MultiXactIds are used",
|
"database \"%s\" must be vacuumed before %u more MultiXactIds are used",
|
||||||
multiWrapLimit - curMulti,
|
multiWrapLimit - curMulti,
|
||||||
oldest_datname,
|
oldest_datname,
|
||||||
multiWrapLimit - curMulti),
|
multiWrapLimit - curMulti),
|
||||||
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
|
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
|
||||||
"You might also need to commit or roll back old prepared transactions.")));
|
"You might also need to commit or roll back old prepared transactions.")));
|
||||||
else
|
else
|
||||||
@@ -2311,8 +2311,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
|
|||||||
(errmsg_plural("database with OID %u must be vacuumed before %u more MultiXactId is used",
|
(errmsg_plural("database with OID %u must be vacuumed before %u more MultiXactId is used",
|
||||||
"database with OID %u must be vacuumed before %u more MultiXactIds are used",
|
"database with OID %u must be vacuumed before %u more MultiXactIds are used",
|
||||||
multiWrapLimit - curMulti,
|
multiWrapLimit - curMulti,
|
||||||
oldest_datoid,
|
oldest_datoid,
|
||||||
multiWrapLimit - curMulti),
|
multiWrapLimit - curMulti),
|
||||||
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
|
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
|
||||||
"You might also need to commit or roll back old prepared transactions.")));
|
"You might also need to commit or roll back old prepared transactions.")));
|
||||||
}
|
}
|
||||||
@@ -2539,10 +2539,9 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
|
|||||||
* obviously can't point to one. It will instead point to the multixact
|
* obviously can't point to one. It will instead point to the multixact
|
||||||
* ID that will be assigned the next time one is needed.
|
* ID that will be assigned the next time one is needed.
|
||||||
*
|
*
|
||||||
* NB: oldestMXact should be the oldest multixact that still exists in
|
* NB: oldestMXact should be the oldest multixact that still exists in the
|
||||||
* the SLRU, unlike in SetMultiXactIdLimit, where we do this same
|
* SLRU, unlike in SetMultiXactIdLimit, where we do this same computation
|
||||||
* computation based on the oldest value that might be referenced in a
|
* based on the oldest value that might be referenced in a table.
|
||||||
* table.
|
|
||||||
*/
|
*/
|
||||||
LWLockAcquire(MultiXactGenLock, LW_SHARED);
|
LWLockAcquire(MultiXactGenLock, LW_SHARED);
|
||||||
if (MultiXactState->nextMXact == oldestMXact)
|
if (MultiXactState->nextMXact == oldestMXact)
|
||||||
@@ -2698,9 +2697,9 @@ int
|
|||||||
MultiXactMemberFreezeThreshold(void)
|
MultiXactMemberFreezeThreshold(void)
|
||||||
{
|
{
|
||||||
MultiXactOffset members;
|
MultiXactOffset members;
|
||||||
uint32 multixacts;
|
uint32 multixacts;
|
||||||
uint32 victim_multixacts;
|
uint32 victim_multixacts;
|
||||||
double fraction;
|
double fraction;
|
||||||
|
|
||||||
ReadMultiXactCounts(&multixacts, &members);
|
ReadMultiXactCounts(&multixacts, &members);
|
||||||
|
|
||||||
@@ -2725,16 +2724,16 @@ MultiXactMemberFreezeThreshold(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* SlruScanDirectory callback.
|
* SlruScanDirectory callback.
|
||||||
* This callback deletes segments that are outside the range determined by
|
* This callback deletes segments that are outside the range determined by
|
||||||
* the given page numbers.
|
* the given page numbers.
|
||||||
*
|
*
|
||||||
* Both range endpoints are exclusive (that is, segments containing any of
|
* Both range endpoints are exclusive (that is, segments containing any of
|
||||||
* those pages are kept.)
|
* those pages are kept.)
|
||||||
*/
|
*/
|
||||||
typedef struct MembersLiveRange
|
typedef struct MembersLiveRange
|
||||||
{
|
{
|
||||||
int rangeStart;
|
int rangeStart;
|
||||||
int rangeEnd;
|
int rangeEnd;
|
||||||
} MembersLiveRange;
|
} MembersLiveRange;
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@@ -2742,15 +2741,15 @@ SlruScanDirCbRemoveMembers(SlruCtl ctl, char *filename, int segpage,
|
|||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
MembersLiveRange *range = (MembersLiveRange *) data;
|
MembersLiveRange *range = (MembersLiveRange *) data;
|
||||||
MultiXactOffset nextOffset;
|
MultiXactOffset nextOffset;
|
||||||
|
|
||||||
if ((segpage == range->rangeStart) ||
|
if ((segpage == range->rangeStart) ||
|
||||||
(segpage == range->rangeEnd))
|
(segpage == range->rangeEnd))
|
||||||
return false; /* easy case out */
|
return false; /* easy case out */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To ensure that no segment is spuriously removed, we must keep track
|
* To ensure that no segment is spuriously removed, we must keep track of
|
||||||
* of new segments added since the start of the directory scan; to do this,
|
* new segments added since the start of the directory scan; to do this,
|
||||||
* we update our end-of-range point as we run.
|
* we update our end-of-range point as we run.
|
||||||
*
|
*
|
||||||
* As an optimization, we can skip looking at shared memory if we know for
|
* As an optimization, we can skip looking at shared memory if we know for
|
||||||
@@ -2819,12 +2818,12 @@ SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
|
|||||||
void
|
void
|
||||||
TruncateMultiXact(void)
|
TruncateMultiXact(void)
|
||||||
{
|
{
|
||||||
MultiXactId oldestMXact;
|
MultiXactId oldestMXact;
|
||||||
MultiXactOffset oldestOffset;
|
MultiXactOffset oldestOffset;
|
||||||
MultiXactOffset nextOffset;
|
MultiXactOffset nextOffset;
|
||||||
mxtruncinfo trunc;
|
mxtruncinfo trunc;
|
||||||
MultiXactId earliest;
|
MultiXactId earliest;
|
||||||
MembersLiveRange range;
|
MembersLiveRange range;
|
||||||
|
|
||||||
Assert(AmCheckpointerProcess() || AmStartupProcess() ||
|
Assert(AmCheckpointerProcess() || AmStartupProcess() ||
|
||||||
!IsPostmasterEnvironment);
|
!IsPostmasterEnvironment);
|
||||||
@@ -2879,7 +2878,6 @@ TruncateMultiXact(void)
|
|||||||
SimpleLruTruncate(MultiXactOffsetCtl,
|
SimpleLruTruncate(MultiXactOffsetCtl,
|
||||||
MultiXactIdToOffsetPage(oldestMXact));
|
MultiXactIdToOffsetPage(oldestMXact));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now, and only now, we can advance the stop point for multixact members.
|
* Now, and only now, we can advance the stop point for multixact members.
|
||||||
* If we did it any sooner, the segments we deleted above might already
|
* If we did it any sooner, the segments we deleted above might already
|
||||||
|
Reference in New Issue
Block a user