Commit 90525d7b authored by Andres Freund's avatar Andres Freund

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
parent 285d8e12
...@@ -1615,8 +1615,14 @@ heap_endscan(HeapScanDesc scan) ...@@ -1615,8 +1615,14 @@ heap_endscan(HeapScanDesc scan)
Size Size
heap_parallelscan_estimate(Snapshot snapshot) heap_parallelscan_estimate(Snapshot snapshot)
{ {
return add_size(offsetof(ParallelHeapScanDescData, phs_snapshot_data), Size sz = offsetof(ParallelHeapScanDescData, phs_snapshot_data);
EstimateSnapshotSpace(snapshot));
if (IsMVCCSnapshot(snapshot))
sz = add_size(sz, EstimateSnapshotSpace(snapshot));
else
Assert(snapshot == SnapshotAny);
return sz;
} }
/* ---------------- /* ----------------
......
...@@ -158,7 +158,7 @@ typedef struct BTShared ...@@ -158,7 +158,7 @@ typedef struct BTShared
/* /*
* This variable-sized field must come last. * This variable-sized field must come last.
* *
* See _bt_parallel_estimate_shared(). * See _bt_parallel_estimate_shared() and heap_parallelscan_estimate().
*/ */
ParallelHeapScanDescData heapdesc; ParallelHeapScanDescData heapdesc;
} BTShared; } BTShared;
...@@ -1405,15 +1405,8 @@ _bt_end_parallel(BTLeader *btleader) ...@@ -1405,15 +1405,8 @@ _bt_end_parallel(BTLeader *btleader)
static Size static Size
_bt_parallel_estimate_shared(Snapshot snapshot) _bt_parallel_estimate_shared(Snapshot snapshot)
{ {
if (!IsMVCCSnapshot(snapshot)) return add_size(offsetof(BTShared, heapdesc),
{ heap_parallelscan_estimate(snapshot));
Assert(snapshot == SnapshotAny);
return sizeof(BTShared);
}
return add_size(offsetof(BTShared, heapdesc) +
offsetof(ParallelHeapScanDescData, phs_snapshot_data),
EstimateSnapshotSpace(snapshot));
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment