Re: A few patches to clarify snapshot management, part 2 - Mailing list pgsql-hackers

From Chao Li
Subject Re: A few patches to clarify snapshot management, part 2
Date
Msg-id A68FDFBD-64A8-41E8-9E3F-D3EEFF9CE75C@gmail.com
Whole thread Raw
In response to Re: A few patches to clarify snapshot management, part 2  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers

> On Dec 19, 2025, at 19:51, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>
>> +/*
>> + * Generic union representing all kind of possible snapshots.  Some have
>> + * type-specific structs.
>> + */
>> +typedef union SnapshotData
>> +{
>> + SnapshotType snapshot_type; /* type of snapshot */
>> +
>> + MVCCSnapshotData mvcc;
>> + DirtySnapshotData dirty;
>> + HistoricMVCCSnapshotData historic_mvcc;
>> + NonVacuumableSnapshotData nonvacuumable;
>>  } SnapshotData;
>> ```
>> > And my big concern is here. This union definition looks unusual,
>> snapshot_type shares the same space with real snapshot bodies, so
>> that once snapshot is assigned to the union, that type info is lost,
>> there would be no way to decide what exact snapshot is stored in
>> SnapshotData.
>
> Each of the structs, MVCCSnapshotData, DirtySnapshotData, etc., contain 'snapshot_type' as the first field, so it's
alwaysavailable. 

Oh, I didn’t notice each of the structs contain “snapshot_type”, in that case, maybe we can just define SnapshotData as
astructure with a single field “snapshot_type”, in the same way as “Node”. 

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Fix memory leak in gist_page_items() of pageinspect
Next
From: "Zhijie Hou (Fujitsu)"
Date:
Subject: RE: Orphaned records in pg_replication_origin_status after subscription drop