Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 90525d7

Browse files
committed
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
1 parent 285d8e1 commit 90525d7

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/backend/access/heap/heapam.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -1615,8 +1615,14 @@ heap_endscan(HeapScanDesc scan)
16151615
Size
16161616
heap_parallelscan_estimate(Snapshot snapshot)
16171617
{
1618-
return add_size(offsetof(ParallelHeapScanDescData, phs_snapshot_data),
1619-
EstimateSnapshotSpace(snapshot));
1618+
Size sz = offsetof(ParallelHeapScanDescData, phs_snapshot_data);
1619+
1620+
if (IsMVCCSnapshot(snapshot))
1621+
sz = add_size(sz, EstimateSnapshotSpace(snapshot));
1622+
else
1623+
Assert(snapshot == SnapshotAny);
1624+
1625+
return sz;
16201626
}
16211627

16221628
/* ----------------

src/backend/access/nbtree/nbtsort.c

+3-10
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ typedef struct BTShared
158158
/*
159159
* This variable-sized field must come last.
160160
*
161-
* See _bt_parallel_estimate_shared().
161+
* See _bt_parallel_estimate_shared() and heap_parallelscan_estimate().
162162
*/
163163
ParallelHeapScanDescData heapdesc;
164164
} BTShared;
@@ -1405,15 +1405,8 @@ _bt_end_parallel(BTLeader *btleader)
14051405
static Size
14061406
_bt_parallel_estimate_shared(Snapshot snapshot)
14071407
{
1408-
if (!IsMVCCSnapshot(snapshot))
1409-
{
1410-
Assert(snapshot == SnapshotAny);
1411-
return sizeof(BTShared);
1412-
}
1413-
1414-
return add_size(offsetof(BTShared, heapdesc) +
1415-
offsetof(ParallelHeapScanDescData, phs_snapshot_data),
1416-
EstimateSnapshotSpace(snapshot));
1408+
return add_size(offsetof(BTShared, heapdesc),
1409+
heap_parallelscan_estimate(snapshot));
14171410
}
14181411

14191412
/*

0 commit comments

Comments
 (0)