@@ -532,24 +532,29 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
532
532
533
533
hash = BID_HASH_FUNC (ctx -> bid );
534
534
slot1 = hash % PtrackContentNblocks ;
535
- slot2 = ((hash << 32 ) | (hash >> 32 )) % PtrackContentNblocks ;
536
535
537
536
update_lsn1 = pg_atomic_read_u64 (& ptrack_map -> entries [slot1 ]);
538
- update_lsn2 = pg_atomic_read_u64 (& ptrack_map -> entries [slot2 ]);
539
537
540
538
if (update_lsn1 != InvalidXLogRecPtr )
541
539
elog (DEBUG3 , "ptrack: update_lsn1 %X/%X of blckno %u of file %s" ,
542
540
(uint32 ) (update_lsn1 >> 32 ), (uint32 ) update_lsn1 ,
543
541
ctx -> bid .blocknum , ctx -> relpath );
544
542
545
- if (update_lsn2 != InvalidXLogRecPtr )
546
- elog (DEBUG3 , "ptrack: update_lsn2 %X/%X of blckno %u of file %s" ,
547
- (uint32 ) (update_lsn1 >> 32 ), (uint32 ) update_lsn2 ,
548
- ctx -> bid .blocknum , ctx -> relpath );
543
+ /* Only probe the second slot if the first one is marked */
544
+ if (update_lsn1 >= ctx -> lsn )
545
+ {
546
+ slot2 = ((hash << 32 ) | (hash >> 32 )) % PtrackContentNblocks ;
547
+ update_lsn2 = pg_atomic_read_u64 (& ptrack_map -> entries [slot2 ]);
549
548
550
- /* Block has been changed since specified LSN. Mark it in the bitmap */
551
- if (update_lsn1 >= ctx -> lsn && update_lsn2 >= ctx -> lsn )
552
- datapagemap_add (& pagemap , ctx -> bid .blocknum % ((BlockNumber ) RELSEG_SIZE ));
549
+ if (update_lsn2 != InvalidXLogRecPtr )
550
+ elog (DEBUG3 , "ptrack: update_lsn2 %X/%X of blckno %u of file %s" ,
551
+ (uint32 ) (update_lsn1 >> 32 ), (uint32 ) update_lsn2 ,
552
+ ctx -> bid .blocknum , ctx -> relpath );
553
+
554
+ /* Block has been changed since specified LSN. Mark it in the bitmap */
555
+ if (update_lsn2 >= ctx -> lsn )
556
+ datapagemap_add (& pagemap , ctx -> bid .blocknum % ((BlockNumber ) RELSEG_SIZE ));
557
+ }
553
558
554
559
ctx -> bid .blocknum += 1 ;
555
560
}
0 commit comments