SerializedSnapshotData alignment

From: Noah Misch <noah(at)leadboat(dot)com>
To: rahilasyed90(at)gmail(dot)com, amit(dot)kapila16(at)gmail(dot)com, robertmhaas(at)gmail(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: SerializedSnapshotData alignment
Date: 2017-02-26 23:43:00
Message-ID: 20170226234300.GB1480178@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear 7b4ac19 authors,

Field ps_snapshot_data usually receives four-byte alignment within
ParallelIndexScanDescData, but it contains the eight-byte whenTaken field.
The select_parallel test dies with SIGBUS on "Oracle Solaris 10 1/13
s10s_u11wos_24a SPARC", building with gcc 4.9.2. Some credible fixes:

1. Move the SerializedSnapshotData declaration from snapmgr.c to snapmgr.h and
declare the ps_snapshot_data field to be of type SerializedSnapshotData.
Probably also add a field "TransactionId xids[FLEXIBLE_ARRAY_MEMBER]" to
SerializedSnapshotData, to assert the variable-length nature.

2. Change "char ps_snapshot_data[FLEXIBLE_ARRAY_MEMBER]" to "int64 ...". I
have attached this in SerializedSnapshot-int64-v1.patch.

3. Change no declarations, and make snapmgr.c memcpy() the
SerializedSnapshotData through a local buffer. I have attached this as
SerializedSnapshot-memcpy-v1.patch.

I like (2) well enough, but I don't see that technique used elsewhere in the
tree. (1) is more typical of PostgreSQL, though I personally like it when
structs can stay private to a file. (3) is also well-attested, particularly
in xlog replay code. I am leaning toward (2). Other opinions?

Field phs_snapshot_data happens to receive eight-byte alignment within
ParallelHeapScanDescData; otherwise, such scans would fail the same way.

Attachment Content-Type Size
SerializedSnapshot-int64-v1.patch text/plain 2.3 KB
SerializedSnapshot-memcpy-v1.patch text/plain 5.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2017-02-27 00:14:34 Re: Statement timeout behavior in extended queries
Previous Message Josh Berkus 2017-02-26 23:05:36 Re: Proposal for changes to recovery.conf API