diff --git a/src/backend/utils/time/sharedsnapshot.c b/src/backend/utils/time/sharedsnapshot.c index e89dfe2136b3382c48a4de55979ab36c16273223..7d83d98ef8aae78b6be43d24e60f0911e797f374 100644 --- a/src/backend/utils/time/sharedsnapshot.c +++ b/src/backend/utils/time/sharedsnapshot.c @@ -226,10 +226,16 @@ SharedSnapshotShmemSize(void) slotSize = MAXALIGN(slotSize); /* - * We only really need max_prepared_xacts; but for safety we - * multiply that by two (to account for slow de-allocation on - * cleanup, for instance). + * We only really need MaxBackends; but for safety we multiply that by two + * (to account for slow de-allocation on cleanup, for instance). + * + * MaxBackends is only somewhat right. What we really want here is the + * MaxBackends value from the QD. But this is at least safe since we know + * we dont need *MORE* than MaxBackends. But in general MaxBackends on a + * QE is going to be bigger than on a QE by a good bit. or at least it + * should be. */ + slotCount = NUM_SHARED_SNAPSHOT_SLOTS; size = offsetof(SharedSnapshotStruct, xips); @@ -263,18 +269,7 @@ CreateSharedSnapshotArray(void) */ sharedSnapshotArray->numSlots = 0; - /* TODO: MaxBackends is only somewhat right. What we really want here - * is the MaxBackends value from the QD. But this is at least - * safe since we know we dont need *MORE* than MaxBackends. But - * in general MaxBackends on a QE is going to be bigger than on a - * QE by a good bit. or at least it should be. - * - * But really, max_prepared_transactions *is* what we want (it - * corresponds to the number of connections allowed on the - * master). - * - * slotCount is initialized in SharedSnapshotShmemSize(). - */ + /* slotCount is initialized in SharedSnapshotShmemSize(). */ sharedSnapshotArray->maxSlots = slotCount; sharedSnapshotArray->nextSlot = 0; diff --git a/src/backend/utils/time/test/sharedsnapshot_test.c b/src/backend/utils/time/test/sharedsnapshot_test.c index 29d6a9f936dcb8070143f8dbcbce4fadb281aefc..259899684a0b7d49db486ad479ed4bd3270aa5e2 100644 --- a/src/backend/utils/time/test/sharedsnapshot_test.c +++ b/src/backend/utils/time/test/sharedsnapshot_test.c @@ -100,10 +100,10 @@ static void test_boundaries_of_CreateSharedSnapshotArray(void **state) { /* - * max_prepared_xacts is used to calculate NUM_SHARED_SNAPSHOT_SLOTS. Make + * MaxBackends is used to calculate NUM_SHARED_SNAPSHOT_SLOTS. Make * it non-zero so that we actually allocate some local snapshot slots. */ - max_prepared_xacts = 2; + MaxBackends = 2; SharedSnapshotStruct *fakeSharedSnapshotArray = NULL; diff --git a/src/include/utils/sharedsnapshot.h b/src/include/utils/sharedsnapshot.h index 58fda9cf85b3822d469598c7023fd332b89b2471..22f7c378fb40643b7a1983e587d2f0b1a9f421fe 100644 --- a/src/include/utils/sharedsnapshot.h +++ b/src/include/utils/sharedsnapshot.h @@ -53,6 +53,6 @@ extern void readSharedLocalSnapshot_forCursor(Snapshot snapshot, DtxContext dist extern void AtEOXact_SharedSnapshot(void); -#define NUM_SHARED_SNAPSHOT_SLOTS (2 * max_prepared_xacts) +#define NUM_SHARED_SNAPSHOT_SLOTS (2 * MaxBackends) #endif /* SHAREDSNAPSHOT_H */