提交 1b0195c9 编写于 作者: P Paul Guo

Update pre-allocated shared snapshot slot number.

Previously it used max_prepared_xacts for shared snapshot slot number. The
reason that it does not use MaxBackends, per comment, is that ideally on QE we
want to use QD MaxBackends for the slot number, and note usually QE MaxBackends
should be greater than QD MaxBackends due to potential multiple gangs per
query. The code previously used max_prepared_xacts finally for the shared
snapshot slot number calculation. That is not correctly given we have read-only
query, and we have one-phase commit now.  Let's use MaxBackends for shared
snapshot slot number calculation for safety though this might waste some memory.
Reviewed-by: Nxiong-gang <gxiong@pivotal.io>
(cherry picked from commit f6c59503)
上级 0c57d9fc
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册