pgsql: Add flush option to pg_logical_emit_message()

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Add flush option to pg_logical_emit_message()
Дата
Msg-id E1qswG6-0015pr-Ms@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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 bae868caf222 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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/173b56f1ef597251fe79d8e71a0df7586ea12549

Modified Files
--------------
contrib/test_decoding/expected/messages.out    |  5 +++--
contrib/test_decoding/sql/messages.sql         |  5 +++--
doc/src/sgml/func.sgml                         |  9 +++++++--
src/backend/catalog/system_functions.sql       | 20 ++++++++++++++++++++
src/backend/replication/logical/logicalfuncs.c |  3 ++-
src/backend/replication/logical/message.c      | 13 +++++++++++--
src/include/catalog/catversion.h               |  2 +-
src/include/catalog/pg_proc.dat                |  4 ++--
src/include/replication/message.h              |  3 ++-
9 files changed, 51 insertions(+), 13 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Nathan Bossart
Дата:
Сообщение: pgsql: windows: msvc: Define STDIN/OUT/ERR_FILENO.
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Count write times when extending relation files for shared buffe