Re: Server crash in pg_replication_slot_advance function

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: amul sul <sulamul(at)gmail(dot)com>
Cc: tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Server crash in pg_replication_slot_advance function
Date: 2018-02-16 10:26:30
Message-ID: CAD21AoBBcNJj-Q6GmGa_VECqHu0FL3KYmVW7mOEDvM7q3UtT+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 16, 2018 at 6:55 PM, amul sul <sulamul(at)gmail(dot)com> wrote:
> On Fri, Feb 16, 2018 at 3:06 PM, amul sul <sulamul(at)gmail(dot)com> wrote:
>> On Fri, Feb 16, 2018 at 1:44 PM, tushar <tushar(dot)ahuja(at)enterprisedb(dot)com> wrote:
>>> Hi,
>> [....]
>>> postgres=# SELECT end_lsn FROM
>>> pg_replication_slot_advance('regression_slot1', '0/2000071');
>>> server closed the connection unexpectedly
>>> This probably means the server terminated abnormally
>>> before or while processing the request.
>>> !>
>>>
>>
>> I am able to reproduce this on the latest master head, the problem is in the
>> following hunk of pg_replication_slot_advance() where oldest LSN value
>> is accessed after releasing replication slot:
>>
>>
>> 476 if (moveto < startlsn)
>> 477 {
>> 478 ReplicationSlotRelease();
>> 479 ereport(ERROR,
>> 480 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
>> 481 errmsg("cannot move slot to %X/%X, minimum is %X/%X",
>> 482 (uint32) (moveto >> 32), (uint32) moveto,
>> 483 (uint32)
>> (MyReplicationSlot->data.confirmed_flush >> 32),
>> 484 (uint32)
>> (MyReplicationSlot->data.confirmed_flush))));
>> 485 }
>> 486
>>
>
> Attached patch proposes a required fix.
>

The change looks good to me. Thank you.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2018-02-16 10:32:39 Re: After an error - pg_replication_slot is dropped
Previous Message Petr Jelinek 2018-02-16 10:26:22 Re: Server crash in pg_replication_slot_advance function