Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 456f469

Browse files
committed
Lock relation in pglogical_apply: fix possible source of #1582
1 parent ea168f2 commit 456f469

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

contrib/mmts/pglogical_apply.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,14 @@ read_rel(StringInfo s, LOCKMODE mode)
744744
old_context = MemoryContextSwitchTo(TopMemoryContext);
745745
pglogical_relid_map_put(remote_relid, local_relid);
746746
MemoryContextSwitchTo(old_context);
747+
return heap_open(local_relid, NoLock);
747748
} else {
748749
nspnamelen = pq_getmsgbyte(s);
749750
s->cursor += nspnamelen;
750751
relnamelen = pq_getmsgbyte(s);
751752
s->cursor += relnamelen;
753+
return heap_open(local_relid, mode);
752754
}
753-
return heap_open(local_relid, NoLock);
754755
}
755756

756757
static void

src/backend/access/transam/twophase.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,6 +2616,7 @@ GetLoggedPreparedXactState(char const *gid)
26162616
GetOldestRestartPoint(&start_lsn, &timeline);
26172617
if (start_lsn != InvalidXLogRecPtr)
26182618
{
2619+
MemoryContext memctx = CurrentMemoryContext;
26192620
xlogreader = XLogReaderAllocate(&read_local_xlog_page, NULL);
26202621
if (!xlogreader)
26212622
ereport(ERROR,
@@ -2732,6 +2733,7 @@ GetLoggedPreparedXactState(char const *gid)
27322733
FlushErrorState();
27332734
}
27342735
PG_END_TRY();
2736+
MemoryContextSwitchTo(memctx);
27352737
XLogReaderFree(xlogreader);
27362738
}
27372739

0 commit comments

Comments
 (0)