Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8cacea7

Browse files
committed
Ensure sufficient alignment for ParallelTableScanDescData in BTShared.
Previously ParallelTableScanDescData was just a member in BTShared,but afterc2fe139 that doesn't guarantee sufficient alignment asspecific AMs might (are likely to) need atomic variables in thestruct.One might think that MAXALIGNing would be sufficient, but as acomment in shm_toc_allocate() explains, that's not enough. For now,copy the hack described there.For parallel sequential scans no such change is needed, as itsallocations go through shm_toc_allocate().An alternative approach would have been to allocate the parallel scandescriptor in a separate TOC entry, but there seems little benefit indoing so.Per buildfarm member dromedary.Author: Andres FreundDiscussion:https://postgr.es/m/20190311203126.ty5gbfz42gjbm6i6@alap3.anarazel.de
1 parentc2fe139 commit8cacea7

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

‎src/backend/access/nbtree/nbtsort.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,21 @@ typedef struct BTShared
157157
boolbrokenhotchain;
158158

159159
/*
160-
*This variable-sized field must come last.
161-
*
162-
*See _bt_parallel_estimate_shared() and table_parallelscan_estimate().
160+
*ParallelTableScanDescData data follows. Can't directly embed here, as
161+
* implementations of the parallel table scan desc interface might need
162+
*stronger alignment.
163163
*/
164-
ParallelTableScanDescDataheapdesc;
165164
}BTShared;
166165

166+
/*
167+
* Return pointer to a BTShared's parallel table scan.
168+
*
169+
* c.f. shm_toc_allocate as to why BUFFERALIGN is used, rather than just
170+
* MAXALIGN.
171+
*/
172+
#defineParallelTableScanFromBTShared(shared) \
173+
(ParallelTableScanDesc) ((char *) (shared) + BUFFERALIGN(sizeof(BTShared)))
174+
167175
/*
168176
* Status for leader in parallel index build.
169177
*/
@@ -1317,7 +1325,8 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request)
13171325
btshared->havedead= false;
13181326
btshared->indtuples=0.0;
13191327
btshared->brokenhotchain= false;
1320-
table_parallelscan_initialize(btspool->heap,&btshared->heapdesc,
1328+
table_parallelscan_initialize(btspool->heap,
1329+
ParallelTableScanFromBTShared(btshared),
13211330
snapshot);
13221331

13231332
/*
@@ -1407,7 +1416,8 @@ _bt_end_parallel(BTLeader *btleader)
14071416
staticSize
14081417
_bt_parallel_estimate_shared(Relationheap,Snapshotsnapshot)
14091418
{
1410-
returnadd_size(offsetof(BTShared,heapdesc),
1419+
/* c.f. shm_toc_allocate as to why BUFFERALIGN is used */
1420+
returnadd_size(BUFFERALIGN(sizeof(BTShared)),
14111421
table_parallelscan_estimate(heap,snapshot));
14121422
}
14131423

@@ -1672,7 +1682,8 @@ _bt_parallel_scan_and_sort(BTSpool *btspool, BTSpool *btspool2,
16721682
/* Join parallel scan */
16731683
indexInfo=BuildIndexInfo(btspool->index);
16741684
indexInfo->ii_Concurrent=btshared->isconcurrent;
1675-
scan=table_beginscan_parallel(btspool->heap,&btshared->heapdesc);
1685+
scan=table_beginscan_parallel(btspool->heap,
1686+
ParallelTableScanFromBTShared(btshared));
16761687
reltuples=IndexBuildHeapScan(btspool->heap,btspool->index,indexInfo,
16771688
true,_bt_build_callback,
16781689
(void*)&buildstate,scan);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp