Re: A few patches to clarify snapshot management, part 2

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: A few patches to clarify snapshot management, part 2
Date: 2025-12-22 02:59:12
Message-ID: A68FDFBD-64A8-41E8-9E3F-D3EEFF9CE75C@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Dec 19, 2025, at 19:51, Heikki Linnakangas <hlinnaka(at)iki(dot)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 always available.

Oh, I didn’t notice each of the structs contain “snapshot_type”, in that case, maybe we can just define SnapshotData as a structure 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/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-12-22 04:46:43 RE: Orphaned records in pg_replication_origin_status after subscription drop
Previous Message Chao Li 2025-12-22 02:41:44 Re: Fix memory leak in gist_page_items() of pageinspect