Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEfKR-0007iQ-CX for pgsql-hackers@arkaria.postgresql.org; Sat, 27 May 2017 17:16:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dEfKP-0004nY-HG for pgsql-hackers@arkaria.postgresql.org; Sat, 27 May 2017 17:16:37 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dEfKN-0004mE-Tw for pgsql-hackers@postgresql.org; Sat, 27 May 2017 17:16:36 +0000 Received: from forward8o.cmail.yandex.net ([2a02:6b8:0:1a72::293]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dEfKK-00019t-DK for pgsql-hackers@postgresql.org; Sat, 27 May 2017 17:16:34 +0000 Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [IPv6:2a02:6b8:0:801::ac]) by forward8o.cmail.yandex.net (Yandex) with ESMTP id 1A90C2201F; Sat, 27 May 2017 20:16:29 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id 3C4DA3EC0AC0; Sat, 27 May 2017 20:16:26 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OYBfBZpRsx-GQw036mb; Sat, 27 May 2017 20:16:26 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=simply.name; s=mail; t=1495905386; bh=K6mx54V+X42rKgyNxWLfA3kH9atBL8WTzNNLSlWtBi8=; h=From:Message-Id:Subject:Date:In-Reply-To:Cc:To:References; b=k5gQwYcQvdEQZLKCeRVCxokT/IMzmV0XBKjwVQbtwRmiRQpbxT5hrmHb/0dd1A6We X4nzAjroGhXS2XwiXzeD493Ot8lzdcb9odM2KaPeAGfwZRuvH/72n9/jbtOgK+iw9J pMMyuZaAARq3dudzcNJF04nRoi7Rx7/leI208WjA= Authentication-Results: smtp2j.mail.yandex.net; dkim=pass header.i=@simply.name X-Yandex-ForeignMX: US X-Yandex-Suid-Status: 1 0,1 0,1 949746412,1 0 From: Vladimir Borodin Message-Id: <060EBFE2-D33E-4CD2-AE58-499A22040F2F@simply.name> Content-Type: multipart/alternative; boundary="Apple-Mail=_67C4008D-3FBE-4C5C-852A-1744D89DE984" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Broken hint bits (freeze) Date: Sat, 27 May 2017 20:16:25 +0300 In-Reply-To: <20170527165609.gpywwbe2fub4llkq@alap3.anarazel.de> Cc: Amit Kapila , Dmitriy Sarafannikov , pgsql-hackers To: Andres Freund References: <2E86EB5F-50ED-4DE2-B14E-98EF8F62B2F2@simply.name> <20170527165609.gpywwbe2fub4llkq@alap3.anarazel.de> X-Mailer: Apple Mail (2.3273) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --Apple-Mail=_67C4008D-3FBE-4C5C-852A-1744D89DE984 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 27 =D0=BC=D0=B0=D1=8F 2017 =D0=B3., =D0=B2 19:56, Andres Freund = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0): >=20 > On 2017-05-27 19:48:24 +0300, Vladimir Borodin wrote: >> Well, actually clean shutdown of master with exit code 0 from `pg_ctl >> stop -m fast` guarantees that all WAL has been replicated to standby. >=20 > It does not. It makes it likely, but the connection to the standby > could be not up just then, you could run into walsender timeout, and a > bunch of other scenarios. AFAIK in this case exit code would not be zero. Even if archiver has not = been able to archive all WALs before timeout for shutting down happened, = exit code will not be zero. >=20 >=20 >> But just in case we also check that "Latest checkpoint's REDO >> location" from control file on old master after shutdown is less than >> pg_last_xlog_replay_location() on standby to be promoted. >=20 > The *redo* location? Or the checkpoint location itself? Because the > latter is what needs to be *equal* than the replay location not less > than. Normally there won't be other records inbetween, but that's not > guaranteed. I've asked about it some time ago [1]. In that case checkpoint location = and redo location were equal after shutdown and last replay location on = standby was higher on 104 bytes (the size of shutdown checkpoint = record). But we do check exactly redo location. Should we change it for checking = checkpoint location? [1] = https://www.postgresql.org/message-id/A7683985-2EC2-40AD-AAAC-B44BD0F29723= %40simply.name >=20 >=20 >> And if something would go wrong in above logic, postgres will not let = you attach old master as a standby of new master. So it is highly = probable not a setup problem. >=20 > There's no such guarantee. There's a bunch of checks that'll somewhat > likely trigger, but nothing more than that. >=20 > - Andres -- May the force be with you=E2=80=A6 https://simply.name --Apple-Mail=_67C4008D-3FBE-4C5C-852A-1744D89DE984 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
27 =D0=BC=D0=B0=D1=8F 2017 =D0=B3., =D0=B2 19:56, Andres = Freund <andres@anarazel.de> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0= =D0=BB(=D0=B0):

On 2017-05-27 19:48:24 +0300, Vladimir = Borodin wrote:
Well, = actually clean shutdown of master with exit code 0 from `pg_ctl
stop -m fast` guarantees that all WAL has been replicated to = standby.

It does not.  It = makes it likely, but the connection to the standby
could = be not up just then, you could run into walsender timeout, and a
bunch of other scenarios.

AFAIK = in this case exit code would not be zero. Even if archiver has not been = able to archive all WALs before timeout for shutting down happened, exit = code will not be zero.



But just in case we also = check that "Latest checkpoint's REDO
location" from = control file on old master after shutdown is less than
pg_last_xlog_replay_location() on standby to be promoted.

The *redo* location? Or the = checkpoint location itself?  Because the
latter is = what needs to be *equal* than the replay location not less
than.  Normally there won't be other records inbetween, = but that's not
guaranteed.

I've = asked about it some time ago [1]. In that case checkpoint location and = redo location were equal after shutdown and last replay location on = standby was higher on 104 bytes (the size of shutdown checkpoint = record).

But we do check exactly = redo location. Should we change it for checking checkpoint = location?




And if = something would go wrong in above logic, postgres will not let you = attach old master as a standby of new master. So it is highly probable = not a setup problem.

There's = no such guarantee.  There's a bunch of checks that'll somewhat
likely trigger, but nothing more than that.

- Andres


--
May the = force be with you=E2=80=A6

= --Apple-Mail=_67C4008D-3FBE-4C5C-852A-1744D89DE984--