I would like to introduce concept of generic WAL logical messages.

These messages just create WAL record with arbitrary data as specified by user. For standard WAL reply, these are basically noop, but in logical decoding they are be decoded and the special callback of the output plugin is be called for them.

These messages can be both transactional (decoded on commit) or non-transactional (decoded immediately). Each message has prefix to differentiate between individual plugins. The prefix has to be registered exactly once (in similar manner as security label providers) to avoid conflicts between plugins.

There are three main use-cases for these:
a) reliable communication between two nodes in multi-master setup - WAL already handles correctly the recovery etc so we don't have to invent new complex code to handle crashes in middle of operations

b) out of order messaging in logical replication - if you want to send something to other node immediately without having to wait for commit for example to acquire remote lock, this can be used for that

c) "queue tables" - combination of this feature (there is SQL interface) and before triggers can be used to create tables for which all inserts only go to the WAL so they can behave like queue without having to store the data in the table itself (kind of the opposite of unlogged tables)

Initial implementation of this proposal is attached.

 Petr Jelinek                  http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment: WAL-Messages-2016-01-01.patch
Description: binary/octet-stream

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to