On Tue, Aug 15, 2023 at 11:37:32AM +0200, Tomas Vondra wrote: > Shouldn't the flush be done only for non-transactional messages? The > transactional case will be flushed by regular commit flush.
Indeed, that would be better. I am sending an updated patch. I'd like to backpatch that, would there be any objections to that? This may depend on how much logical solutions depend on this routine. -- Michael
diff --git a/src/backend/replication/logical/message.c b/src/backend/replication/logical/message.c index c5de14afc6..cb3a806114 100644 --- a/src/backend/replication/logical/message.c +++ b/src/backend/replication/logical/message.c @@ -47,6 +47,7 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size, bool transactional) { xl_logical_message xlrec; + XLogRecPtr lsn; /* * Force xid to be allocated if we're emitting a transactional message. @@ -71,7 +72,15 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size, /* allow origin filtering */ XLogSetRecordFlags(XLOG_INCLUDE_ORIGIN); - return XLogInsert(RM_LOGICALMSG_ID, XLOG_LOGICAL_MESSAGE); + lsn = XLogInsert(RM_LOGICALMSG_ID, XLOG_LOGICAL_MESSAGE); + + /* + * Make sure that the message hits disk before leaving if not emitting a + * transactional message. + */ + if (!transactional) + XLogFlush(lsn); + return lsn; } /*
signature.asc
Description: PGP signature