mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +03:00
Add flush option to pg_logical_emit_message()
Since its introduction, LogLogicalMessage() (via the SQL interface
pg_logical_emit_message()) has never included a call to XLogFlush(),
causing it to potentially lose messages on a crash when used in
non-transactional mode. This has come up to me as a problem while
playing with ideas to design a test suite for what has become
039_end_of_wal.pl introduced in bae868caf2
by Thomas Munro, because
there are no direct ways to force a WAL flush via SQL.
The default is false, to not flush messages and influence existing
use-cases where this function could be used. If set to true, the
message emitted is flushed before returning back to the caller, making
the message durable on crash. This new option has no effect when using
pg_logical_emit_message() in transactional mode, as the record's flush
is guaranteed by the WAL record generated by the transaction committed.
Two queries of test_decoding are tweaked to cover the new code path for
the flush.
Bump catalog version.
Author: Michael Paquier
Reviewed-by: Andres Freund, Amit Kapila, Fujii Masao, Tung Nguyen, Tomas
Vondra
Discussion: https://postgr.es/m/ZNsdThSe2qgsfs7R@paquier.xyz
This commit is contained in:
@@ -57,6 +57,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202310161
|
||||
#define CATALOG_VERSION_NO 202310181
|
||||
|
||||
#endif
|
||||
|
@@ -11167,11 +11167,11 @@
|
||||
prosrc => 'pg_replication_slot_advance' },
|
||||
{ oid => '3577', descr => 'emit a textual logical decoding message',
|
||||
proname => 'pg_logical_emit_message', provolatile => 'v', proparallel => 'u',
|
||||
prorettype => 'pg_lsn', proargtypes => 'bool text text',
|
||||
prorettype => 'pg_lsn', proargtypes => 'bool text text bool',
|
||||
prosrc => 'pg_logical_emit_message_text' },
|
||||
{ oid => '3578', descr => 'emit a binary logical decoding message',
|
||||
proname => 'pg_logical_emit_message', provolatile => 'v', proparallel => 'u',
|
||||
prorettype => 'pg_lsn', proargtypes => 'bool text bytea',
|
||||
prorettype => 'pg_lsn', proargtypes => 'bool text bytea bool',
|
||||
prosrc => 'pg_logical_emit_message_bytea' },
|
||||
|
||||
# event triggers
|
||||
|
@@ -30,7 +30,8 @@ typedef struct xl_logical_message
|
||||
#define SizeOfLogicalMessage (offsetof(xl_logical_message, message))
|
||||
|
||||
extern XLogRecPtr LogLogicalMessage(const char *prefix, const char *message,
|
||||
size_t size, bool transactional);
|
||||
size_t size, bool transactional,
|
||||
bool flush);
|
||||
|
||||
/* RMGR API */
|
||||
#define XLOG_LOGICAL_MESSAGE 0x00
|
||||
|
Reference in New Issue
Block a user