mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Revert the addition of GetMaxBackends() and related stuff.
This reverts commits0147fc7,4567596,aa64f23, and5ecd018. There is no longer agreement that introducing this function was the right way to address the problem. The consensus now seems to favor trying to make a correct value for MaxBackends available to mdules executing their _PG_init() functions. Nathan Bossart Discussion: http://postgr.es/m/20220323045229.i23skfscdbvrsuxa@jrouhaud
This commit is contained in:
@@ -2072,7 +2072,7 @@ BTreeShmemSize(void)
|
||||
Size size;
|
||||
|
||||
size = offsetof(BTVacInfo, vacuums);
|
||||
size = add_size(size, mul_size(GetMaxBackends(), sizeof(BTOneVacInfo)));
|
||||
size = add_size(size, mul_size(MaxBackends, sizeof(BTOneVacInfo)));
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -2101,7 +2101,7 @@ BTreeShmemInit(void)
|
||||
btvacinfo->cycle_ctr = (BTCycleId) time(NULL);
|
||||
|
||||
btvacinfo->num_vacuums = 0;
|
||||
btvacinfo->max_vacuums = GetMaxBackends();
|
||||
btvacinfo->max_vacuums = MaxBackends;
|
||||
}
|
||||
else
|
||||
Assert(found);
|
||||
|
||||
@@ -282,11 +282,12 @@ typedef struct MultiXactStateData
|
||||
} MultiXactStateData;
|
||||
|
||||
/*
|
||||
* Pointers to the state data in shared memory
|
||||
*
|
||||
* The index of the last element of the OldestMemberMXactId and
|
||||
* OldestVisibleMXactId arrays can be obtained with GetMaxOldestSlot().
|
||||
* Last element of OldestMemberMXactId and OldestVisibleMXactId arrays.
|
||||
* Valid elements are (1..MaxOldestSlot); element 0 is never used.
|
||||
*/
|
||||
#define MaxOldestSlot (MaxBackends + max_prepared_xacts)
|
||||
|
||||
/* Pointers to the state data in shared memory */
|
||||
static MultiXactStateData *MultiXactState;
|
||||
static MultiXactId *OldestMemberMXactId;
|
||||
static MultiXactId *OldestVisibleMXactId;
|
||||
@@ -341,7 +342,6 @@ static void MultiXactIdSetOldestVisible(void);
|
||||
static void RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
|
||||
int nmembers, MultiXactMember *members);
|
||||
static MultiXactId GetNewMultiXactId(int nmembers, MultiXactOffset *offset);
|
||||
static inline int GetMaxOldestSlot(void);
|
||||
|
||||
/* MultiXact cache management */
|
||||
static int mxactMemberComparator(const void *arg1, const void *arg2);
|
||||
@@ -662,17 +662,6 @@ MultiXactIdSetOldestMember(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the index of the last element of the OldestMemberMXactId and
|
||||
* OldestVisibleMXactId arrays. Valid elements are (1..MaxOldestSlot); element
|
||||
* 0 is never used.
|
||||
*/
|
||||
static inline int
|
||||
GetMaxOldestSlot(void)
|
||||
{
|
||||
return GetMaxBackends() + max_prepared_xacts;
|
||||
}
|
||||
|
||||
/*
|
||||
* MultiXactIdSetOldestVisible
|
||||
* Save the oldest MultiXactId this transaction considers possibly live.
|
||||
@@ -695,7 +684,6 @@ MultiXactIdSetOldestVisible(void)
|
||||
if (!MultiXactIdIsValid(OldestVisibleMXactId[MyBackendId]))
|
||||
{
|
||||
MultiXactId oldestMXact;
|
||||
int maxOldestSlot = GetMaxOldestSlot();
|
||||
int i;
|
||||
|
||||
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
|
||||
@@ -709,7 +697,7 @@ MultiXactIdSetOldestVisible(void)
|
||||
if (oldestMXact < FirstMultiXactId)
|
||||
oldestMXact = FirstMultiXactId;
|
||||
|
||||
for (i = 1; i <= maxOldestSlot; i++)
|
||||
for (i = 1; i <= MaxOldestSlot; i++)
|
||||
{
|
||||
MultiXactId thisoldest = OldestMemberMXactId[i];
|
||||
|
||||
@@ -1843,7 +1831,7 @@ MultiXactShmemSize(void)
|
||||
/* We need 2*MaxOldestSlot + 1 perBackendXactIds[] entries */
|
||||
#define SHARED_MULTIXACT_STATE_SIZE \
|
||||
add_size(offsetof(MultiXactStateData, perBackendXactIds) + sizeof(MultiXactId), \
|
||||
mul_size(sizeof(MultiXactId) * 2, GetMaxOldestSlot()))
|
||||
mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
|
||||
|
||||
size = SHARED_MULTIXACT_STATE_SIZE;
|
||||
size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
|
||||
@@ -1894,7 +1882,7 @@ MultiXactShmemInit(void)
|
||||
* since we only use indexes 1..MaxOldestSlot in each array.
|
||||
*/
|
||||
OldestMemberMXactId = MultiXactState->perBackendXactIds;
|
||||
OldestVisibleMXactId = OldestMemberMXactId + GetMaxOldestSlot();
|
||||
OldestVisibleMXactId = OldestMemberMXactId + MaxOldestSlot;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2519,7 +2507,6 @@ GetOldestMultiXactId(void)
|
||||
{
|
||||
MultiXactId oldestMXact;
|
||||
MultiXactId nextMXact;
|
||||
int maxOldestSlot = GetMaxOldestSlot();
|
||||
int i;
|
||||
|
||||
/*
|
||||
@@ -2538,7 +2525,7 @@ GetOldestMultiXactId(void)
|
||||
nextMXact = FirstMultiXactId;
|
||||
|
||||
oldestMXact = nextMXact;
|
||||
for (i = 1; i <= maxOldestSlot; i++)
|
||||
for (i = 1; i <= MaxOldestSlot; i++)
|
||||
{
|
||||
MultiXactId thisoldest;
|
||||
|
||||
|
||||
@@ -264,7 +264,6 @@ TwoPhaseShmemInit(void)
|
||||
{
|
||||
GlobalTransaction gxacts;
|
||||
int i;
|
||||
int max_backends = GetMaxBackends();
|
||||
|
||||
Assert(!found);
|
||||
TwoPhaseState->freeGXacts = NULL;
|
||||
@@ -298,7 +297,7 @@ TwoPhaseShmemInit(void)
|
||||
* prepared transaction. Currently multixact.c uses that
|
||||
* technique.
|
||||
*/
|
||||
gxacts[i].dummyBackendId = max_backends + 1 + i;
|
||||
gxacts[i].dummyBackendId = MaxBackends + 1 + i;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user