Re: BUG #15346: Replica fails to start after the crash

From: Alexander Kukushkin <cyberdemn(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15346: Replica fails to start after the crash
Date: 2018-08-23 10:06:59
Message-ID: CAFh8B=nHdsX83hTZMqGqbht39ud+DRQOv4_Te+xu3DuPssQbZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi,

I think I am getting closer:

If I start postgres without background worker, then works following code:

// https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/access/nbtree/nbtxlog.c;h=c536e224321dbc46574aa76876b9d49fa4b5e9a4;hb=REL9_6_10#l549
if (CountDBBackends(InvalidOid) == 0)
return latestRemovedXid;

And it returns from the btree_xlog_delete_get_latestRemovedXid function.

In case if we have a background worker, then
CountDBBackends(InvalidOid) = 1 and as a result it aborts.

Comment before if statement clearly tells about possible race condition:
/*
* If there's nothing running on the standby we don't need to derive a
* full latestRemovedXid value, so use a fast path out of here. This
* returns InvalidTransactionId, and so will conflict with all HS
* transactions; but since we just worked out that that's zero people,
* it's OK.
*
* XXX There is a race condition here, which is that a new backend might
* start just after we look. If so, it cannot need to
conflict, but this
* coding will result in throwing a conflict anyway.
*/

Regards,
--
Alexander Kukushkin

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Klika 2018-08-23 11:40:38 11 beta 3 / ROLLBACK TO SAVEPOINT regression in PLPGSQL
Previous Message PG Bug reporting form 2018-08-23 09:32:54 BUG #15348: Postgres 8.4 accepte les connexions entrantes

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Dolgov 2018-08-23 10:31:47 Re: [HACKERS] advanced partition matching algorithm for partition-wise join
Previous Message Fabien COELHO 2018-08-23 09:46:32 Re: [HACKERS] proposal: schema variables