summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund2019-01-15 20:19:21 +0000
committerAndres Freund2019-01-15 20:19:21 +0000
commit90525d7b4e0fe5ebd53960cd7ef59ee11ff06516 (patch)
treed23008d7e6b11540e95a9b28b7daed450f0357a2 /src
parent285d8e12055f27bce5675e93fef365b6c337f2b3 (diff)
Don't duplicate parallel seqscan shmem sizing logic in nbtree.
This is architecturally mildly problematic, which becomes more pronounced with the upcoming introduction of pluggable storage. To fix, teach heap_parallelscan_estimate() to deal with SnapshotAny snapshots, and then use it from _bt_parallel_estimate_shared(). Author: Andres Freund Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/heap/heapam.c10
-rw-r--r--src/backend/access/nbtree/nbtsort.c13
2 files changed, 11 insertions, 12 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index f7b08ffdd13..9afbc8228de 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -1615,8 +1615,14 @@ heap_endscan(HeapScanDesc scan)
Size
heap_parallelscan_estimate(Snapshot snapshot)
{
- return add_size(offsetof(ParallelHeapScanDescData, phs_snapshot_data),
- EstimateSnapshotSpace(snapshot));
+ Size sz = offsetof(ParallelHeapScanDescData, phs_snapshot_data);
+
+ if (IsMVCCSnapshot(snapshot))
+ sz = add_size(sz, EstimateSnapshotSpace(snapshot));
+ else
+ Assert(snapshot == SnapshotAny);
+
+ return sz;
}
/* ----------------
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 83966dc4d41..5cc3cf57e22 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -158,7 +158,7 @@ typedef struct BTShared
/*
* This variable-sized field must come last.
*
- * See _bt_parallel_estimate_shared().
+ * See _bt_parallel_estimate_shared() and heap_parallelscan_estimate().
*/
ParallelHeapScanDescData heapdesc;
} BTShared;
@@ -1405,15 +1405,8 @@ _bt_end_parallel(BTLeader *btleader)
static Size
_bt_parallel_estimate_shared(Snapshot snapshot)
{
- if (!IsMVCCSnapshot(snapshot))
- {
- Assert(snapshot == SnapshotAny);
- return sizeof(BTShared);
- }
-
- return add_size(offsetof(BTShared, heapdesc) +
- offsetof(ParallelHeapScanDescData, phs_snapshot_data),
- EstimateSnapshotSpace(snapshot));
+ return add_size(offsetof(BTShared, heapdesc),
+ heap_parallelscan_estimate(snapshot));
}
/*