Skip to content

Commit 6a754f7

Browse files
leomy-ship-it
authored andcommitted
Fix: use correct offset to access members of Serialized Snapshot Data
1 parent 43e26c7 commit 6a754f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/utils/time/snapmgr.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,13 +2592,19 @@ RestoreSnapshot(char *start_address)
25922592
if (serialized_snapshot.haveDistribSnapshot &&
25932593
serialized_snapshot.ds_count > 0)
25942594
{
2595+
Size ds_off = sizeof(SerializedSnapshotData) +
2596+
serialized_snapshot.xcnt * sizeof(TransactionId) +
2597+
serialized_snapshot.subxcnt * sizeof(TransactionId);
2598+
Size ds_lmoff = ds_off +
2599+
serialized_snapshot.ds_count * sizeof(DistributedTransactionId);
2600+
25952601
snapshot->distribSnapshotWithLocalMapping.ds.inProgressXidArray =
25962602
(DistributedTransactionId*) ((char *) snapshot + dsoff);
25972603
snapshot->distribSnapshotWithLocalMapping.inProgressMappedLocalXids =
25982604
(TransactionId*) ((char *) snapshot + dslmoff);
25992605

26002606
memcpy(snapshot->distribSnapshotWithLocalMapping.ds.inProgressXidArray,
2601-
(DistributedTransactionId*) (start_address + dsoff),
2607+
(DistributedTransactionId*) (start_address + ds_off),
26022608
serialized_snapshot.ds_count *
26032609
sizeof(DistributedTransactionId));
26042610

@@ -2608,7 +2614,7 @@ RestoreSnapshot(char *start_address)
26082614
0,
26092615
serialized_snapshot.ds_count * sizeof(TransactionId));
26102616
memcpy(snapshot->distribSnapshotWithLocalMapping.inProgressMappedLocalXids,
2611-
(TransactionId*) (start_address + dslmoff),
2617+
(TransactionId*) (start_address + ds_lmoff),
26122618
serialized_snapshot.currentLocalXidsCount *
26132619
sizeof(TransactionId));
26142620
}

0 commit comments

Comments
 (0)