Re: logical replication busy-waiting on a lock

From: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Subject: Re: logical replication busy-waiting on a lock
Date: 2017-06-03 02:50:00
Message-ID: 8532a452-bc7d-65cd-90d0-5a004c58833e@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/06/17 03:25, Andres Freund wrote:
>
>> That should solve the original problem reported here.
>
> Did you verify that?
>

Yes, I tried to manually create multiple exported logical decoding
snapshots in parallel and read data from them and it worked fine, while
it blocked before.

>
>> @@ -1741,17 +1741,17 @@ GetSerializableTransactionSnapshotInt(Snapshot snapshot,
>> } while (!sxact);
>>
>> /* Get the snapshot, or check that it's safe to use */
>> - if (!TransactionIdIsValid(sourcexid))
>> + if (!sourcevxid)
>> snapshot = GetSnapshotData(snapshot);
>> - else if (!ProcArrayInstallImportedXmin(snapshot->xmin, sourcexid))
>> + else if (!ProcArrayInstallImportedXmin(snapshot->xmin, sourcevxid))
>> {
>> ReleasePredXact(sxact);
>> LWLockRelease(SerializableXactHashLock);
>> ereport(ERROR,
>> (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
>> errmsg("could not import the requested snapshot"),
>> - errdetail("The source transaction %u is not running anymore.",
>> - sourcexid)));
>> + errdetail("The source virtual transaction %d/%u is not running anymore.",
>> + sourcevxid->backendId, sourcevxid->localTransactionId)));
>
> Hm, this is a harder to read. Wonder if we should add a pid field, that'd
> make it a bit easier to interpret?
>

Agreed, see attached. We have to pass the pid around a bit but I don't
think it's too bad.

One thing I don't like is the GetLastLocalTransactionId() that I had to
add because we clear the proc->lxid before we get to AtEOXact_Snapshot()
but I don't have better solution there.

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

Attachment Content-Type Size
0002-Don-t-assign-xid-to-logical-decoding-snapshots.patch invalid/octet-stream 3.2 KB
0001-Use-virtual-transaction-instead-of-normal-ones-in-ex.patch invalid/octet-stream 17.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2017-06-03 02:50:59 Re: logical replication - still unstable after all these months
Previous Message Mark Kirkwood 2017-06-03 02:45:46 Re: logical replication - still unstable after all these months