Skip to content

Commit 9bc76c4

Browse files
committed
Only initialize WAL shmem once in EXEC_BACKEND builds
This only affects EXEC_BACKEND/Windows builds which we currently do not support, but we fix this anyway to make the code more consistent and easier to understand since we try to care about this in other places. In the future we may want to add CI and proper support for EXEC_BACKEND builds. The issue was originally found by Zsolt Parragi.
1 parent 13c1038 commit 9bc76c4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

contrib/pg_tde/src/access/pg_tde_xlog_smgr.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,28 @@ TDEXLogEncryptStateSize(void)
160160
void
161161
TDEXLogShmemInit(void)
162162
{
163-
bool foundBuf;
163+
bool found;
164164

165165
EncryptionState = (EncryptionStateData *)
166166
ShmemInitStruct("TDE XLog Encryption State",
167167
TDEXLogEncryptStateSize(),
168-
&foundBuf);
168+
&found);
169169

170-
memset(EncryptionState, 0, sizeof(EncryptionStateData));
170+
if (!found)
171+
{
172+
memset(EncryptionState, 0, sizeof(EncryptionStateData));
173+
174+
pg_atomic_init_u64(&EncryptionState->enc_key_lsn, 0);
175+
176+
elog(DEBUG1, "pg_tde: initialized encryption buffer %lu bytes", TDEXLogEncryptStateSize());
177+
}
171178

172179
if (EncryptXLog)
173180
{
174181
EncryptionBuf = (char *) TYPEALIGN(PG_IO_ALIGN_SIZE, ((char *) EncryptionState) + sizeof(EncryptionStateData));
175182

176183
Assert((char *) EncryptionState + TDEXLogEncryptStateSize() >= (char *) EncryptionBuf + TDEXLogEncryptBuffSize());
177184
}
178-
179-
pg_atomic_init_u64(&EncryptionState->enc_key_lsn, 0);
180-
181-
elog(DEBUG1, "pg_tde: initialized encryption buffer %lu bytes", TDEXLogEncryptStateSize());
182185
}
183186

184187
#else /* !FRONTEND */

0 commit comments

Comments
 (0)