Re: Proposal: Generic WAL logical messages

From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, Simon Riggs <simon(at)2ndQuadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Craig Ringer <craig(at)2ndquadrant(dot)com>
Subject: Re: Proposal: Generic WAL logical messages
Date: 2016-02-29 21:10:05
Message-ID: 56D4B3AD.5000207@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

attached is the newest version of the patch.

I removed the registry, renamed the 'send' to 'emit', documented the
callback parameters properly. I also added the test to ddl.sql for the
serialization and deserialization (and of course found a bug there) and
in general fixed all the stuff Andres reported.

(see more inline)

On 28/02/16 22:55, Andres Freund wrote:
>
>
>>>
>>>> +void
>>>> +ReorderBufferQueueMessage(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn,
>>>> + bool transactional, const char *prefix, Size msg_sz,
>>>> + const char *msg)
>>>> +{
>>>> + ReorderBufferTXN *txn = NULL;
>>>> +
>>>> + if (transactional)
>>>> + {
>>>> + ReorderBufferChange *change;
>>>> +
>>>> + txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
>>>> +
>>>> + Assert(xid != InvalidTransactionId);
>>>> + Assert(txn != NULL);
>>>> +
>>>> + change = ReorderBufferGetChange(rb);
>>>> + change->action = REORDER_BUFFER_CHANGE_MESSAGE;
>>>> + change->data.msg.transactional = true;
>>>> + change->data.msg.prefix = pstrdup(prefix);
>>>> + change->data.msg.message_size = msg_sz;
>>>> + change->data.msg.message = palloc(msg_sz);
>>>> + memcpy(change->data.msg.message, msg, msg_sz);
>>>> +
>>>> + ReorderBufferQueueChange(rb, xid, lsn, change);
>>>> + }
>>>> + else
>>>> + {
>>>> + rb->message(rb, txn, lsn, transactional, prefix, msg_sz, msg);
>>>> + }
>>>> +}
>>>
>>>
>>> This approach prohibts catalog access when processing a nontransaction
>>> message as there's no snapshot set up.
>>>
>>
>> Hmm I do see usefulness in having snapshot, although I wonder if that does
>> not kill the point of non-transactional messages.
>
> I don't see how it would? It'd obviously have to be the catalog/historic
> snapshot a transaction would have had if it started in that moment in
> the original WAL stream?
>
>
>> Question is then though which snapshot should the message see,
>> base_snapshot of transaction?
>
> Well, there'll not be a transaction, but something like snapbuild.c's
> ->snapshot ought to do the trick.
>

Ok I added interface which returns either existing snapshot or makes new
one, seems like the most reasonable thing to do to me.

>
>> That would mean we'd have to call SnapBuildProcessChange for
>> non-transactional messages which we currently avoid. Alternatively we
>> could probably invent lighter version of that interface that would
>> just make sure builder->snapshot is valid and if not then build it
>
> I think the latter is probably the direction we should go in.
>
>
>> I am honestly sure if that's a win or not.
>
> I think it'll be confusing (bug inducing) if there's no snapshot for
> non-transactional messages but for transactional ones, and it'll
> severely limit the usefulness of the interface.
>

Nono, I meant I am not sure if special interface is a win over just
using SnapBuildProcessChange() in practice.

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

Attachment Content-Type Size
logical-messages-2016-02-29.patch application/x-patch 39.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2016-02-29 21:12:45 Re: Minor typo in syncrep.c
Previous Message Oleg Bartunov 2016-02-29 20:17:39 Re: [PATCH] we have added support for box type in SP-GiST index