Skip to content

Commit 0222be1

Browse files
committed
Fix alignment problems with SharedInvalSmgrMsg.
SharedInvalSmgrMsg can't require 8-byte alignment, because then SharedInvalidationMessage will require 8-byte alignment, which will then cause ParseCommitRecord to fail on machines that are picky about alignment, because it assumes that everything that gets packed into a commit record requires only 4-byte alignment. Another problem with 05d4cbf. Discussion: http://postgr.es/m/3825454.1664310917@sss.pgh.pa.us
1 parent d0b1dbc commit 0222be1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/backend/utils/cache/inval.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,9 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
663663
*/
664664
RelFileLocatorBackend rlocator;
665665

666-
rlocator.locator = msg->sm.rlocator;
666+
rlocator.locator.dbOid = msg->sm.dbOid;
667+
rlocator.locator.spcOid = msg->sm.spcOid;
668+
rlocator.locator.relNumber = (((uint64) msg->sm.relNumber_hi) << 32) | msg->sm.relNumber_lo;
667669
rlocator.backend = (msg->sm.backend_hi << 16) | (int) msg->sm.backend_lo;
668670
smgrcloserellocator(rlocator);
669671
}
@@ -1466,7 +1468,10 @@ CacheInvalidateSmgr(RelFileLocatorBackend rlocator)
14661468
msg.sm.id = SHAREDINVALSMGR_ID;
14671469
msg.sm.backend_hi = rlocator.backend >> 16;
14681470
msg.sm.backend_lo = rlocator.backend & 0xffff;
1469-
msg.sm.rlocator = rlocator.locator;
1471+
msg.sm.dbOid = rlocator.locator.dbOid;
1472+
msg.sm.spcOid = rlocator.locator.spcOid;
1473+
msg.sm.relNumber_hi = rlocator.locator.relNumber >> 32;
1474+
msg.sm.relNumber_lo = rlocator.locator.relNumber & 0xffffffff;
14701475
/* check AddCatcacheInvalidationMessage() for an explanation */
14711476
VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
14721477

src/include/storage/sinval.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,14 @@ typedef struct
8686

8787
typedef struct
8888
{
89-
/* note: field layout chosen to pack into 16 bytes */
89+
/* note: field layout chosen to pack into 20 bytes */
9090
int8 id; /* type field --- must be first */
9191
int8 backend_hi; /* high bits of backend ID, if temprel */
9292
uint16 backend_lo; /* low bits of backend ID, if temprel */
93-
RelFileLocator rlocator; /* spcOid, dbOid, relNumber */
93+
Oid dbOid;
94+
Oid spcOid;
95+
uint32 relNumber_hi; /* avoid 8 byte alignment requirement */
96+
uint32 relNumber_lo;
9497
} SharedInvalSmgrMsg;
9598

9699
#define SHAREDINVALRELMAP_ID (-4)

0 commit comments

Comments
 (0)