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

Commit54562c9

Browse files
committed
Improve Asserts checking relation matching in parallel scans.
table_beginscan_parallel and index_beginscan_parallel containAsserts checking that the relation a worker will use ina parallel scan is the same one the leader intended. However,they were checking for relation OID match, which was not strongenough to detect the mismatch problem fixed in126ec0b.What would be strong enough is to compare relfilenodes instead.Arguably, that's a saner definition anyway, since a scan surelyoperates on a physical relation not a logical one. Hence,store and compare RelFileLocators not relation OIDs. Alsoensure that index_beginscan_parallel checks the index identitynot just the table identity.Discussion:https://postgr.es/m/2127254.1726789524@sss.pgh.pa.us
1 parentafb03e2 commit54562c9

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

‎src/backend/access/index/indexam.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ index_parallelscan_initialize(Relation heapRelation, Relation indexRelation,
500500
EstimateSnapshotSpace(snapshot));
501501
offset=MAXALIGN(offset);
502502

503-
target->ps_relid=RelationGetRelid(heapRelation);
504-
target->ps_indexid=RelationGetRelid(indexRelation);
503+
target->ps_locator=heapRelation->rd_locator;
504+
target->ps_indexlocator=indexRelation->rd_locator;
505505
target->ps_offset=offset;
506506
SerializeSnapshot(snapshot,target->ps_snapshot_data);
507507

@@ -544,7 +544,9 @@ index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys,
544544
Snapshotsnapshot;
545545
IndexScanDescscan;
546546

547-
Assert(RelationGetRelid(heaprel)==pscan->ps_relid);
547+
Assert(RelFileLocatorEquals(heaprel->rd_locator,pscan->ps_locator));
548+
Assert(RelFileLocatorEquals(indexrel->rd_locator,pscan->ps_indexlocator));
549+
548550
snapshot=RestoreSnapshot(pscan->ps_snapshot_data);
549551
RegisterSnapshot(snapshot);
550552
scan=index_beginscan_internal(indexrel,nkeys,norderbys,snapshot,

‎src/backend/access/table/tableam.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ table_beginscan_parallel(Relation relation, ParallelTableScanDesc pscan)
168168
uint32flags=SO_TYPE_SEQSCAN |
169169
SO_ALLOW_STRAT |SO_ALLOW_SYNC |SO_ALLOW_PAGEMODE;
170170

171-
Assert(RelationGetRelid(relation)==pscan->phs_relid);
171+
Assert(RelFileLocatorEquals(relation->rd_locator,pscan->phs_locator));
172172

173173
if (!pscan->phs_snapshot_any)
174174
{
@@ -389,7 +389,7 @@ table_block_parallelscan_initialize(Relation rel, ParallelTableScanDesc pscan)
389389
{
390390
ParallelBlockTableScanDescbpscan= (ParallelBlockTableScanDesc)pscan;
391391

392-
bpscan->base.phs_relid=RelationGetRelid(rel);
392+
bpscan->base.phs_locator=rel->rd_locator;
393393
bpscan->phs_nblocks=RelationGetNumberOfBlocks(rel);
394394
/* compare phs_syncscan initialization to similar logic in initscan */
395395
bpscan->base.phs_syncscan=synchronize_seqscans&&

‎src/include/access/relscan.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include"access/itup.h"
1919
#include"port/atomics.h"
2020
#include"storage/buf.h"
21+
#include"storage/relfilelocator.h"
2122
#include"storage/spin.h"
2223
#include"utils/relcache.h"
2324

@@ -62,7 +63,7 @@ typedef struct TableScanDescData *TableScanDesc;
6263
*/
6364
typedefstructParallelTableScanDescData
6465
{
65-
Oidphs_relid;/*OID of relation to scan */
66+
RelFileLocatorphs_locator;/*physical relation to scan */
6667
boolphs_syncscan;/* report location to syncscan logic? */
6768
boolphs_snapshot_any;/* SnapshotAny, not phs_snapshot_data? */
6869
Sizephs_snapshot_off;/* data for snapshot */
@@ -169,8 +170,8 @@ typedef struct IndexScanDescData
169170
/* Generic structure for parallel scans */
170171
typedefstructParallelIndexScanDescData
171172
{
172-
Oidps_relid;
173-
Oidps_indexid;
173+
RelFileLocatorps_locator;/* physical table relation to scan */
174+
RelFileLocatorps_indexlocator;/* physical index relation to scan */
174175
Sizeps_offset;/* Offset in bytes of am specific structure */
175176
charps_snapshot_data[FLEXIBLE_ARRAY_MEMBER];
176177
}ParallelIndexScanDescData;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp