Skip to content

Commit 17d24ec

Browse files
committed
Fixing flaky crash after 17.5 merge
The 17.5 release includes a bugfix for the smgrcode: previously if smgropen failed, smgrclose wasn't called. In our case we tried to retrieve the key before calling mdopen in smgropen, which meant that the open call failed before the data initialization in mdopen, which sometimes caused mdclose to crash. The fix is simple: as mdopen only zero initializes some data, we call it before trying to retrieve the principal key. This way the failure happens after every data structure is set up properly.
1 parent dee5a15 commit 17d24ec

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

contrib/pg_tde/src/smgr/pg_tde_smgr.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ static void
250250
tde_mdopen(SMgrRelation reln)
251251
{
252252
TDESMgrRelation tdereln = (TDESMgrRelation) reln;
253-
InternalKey *key = tde_smgr_get_key(&reln->smgr_rlocator);
253+
InternalKey *key;
254+
255+
mdopen(reln);
256+
257+
key = tde_smgr_get_key(&reln->smgr_rlocator);
254258

255259
if (key)
256260
{
@@ -261,7 +265,6 @@ tde_mdopen(SMgrRelation reln)
261265
{
262266
tdereln->encrypted_relation = false;
263267
}
264-
mdopen(reln);
265268
}
266269

267270
static const struct f_smgr tde_smgr = {

0 commit comments

Comments
 (0)