Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jqZmj-0004oA-5B for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Jul 2020 10:16:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jqZmg-0003Di-5R for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Jul 2020 10:16:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jqZmf-0003DX-JM for pgsql-hackers@lists.postgresql.org; Wed, 01 Jul 2020 10:16:05 +0000 Received: from mail.dalibo.com ([212.85.157.172]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jqZmY-0004Js-Qr for pgsql-hackers@lists.postgresql.org; Wed, 01 Jul 2020 10:16:04 +0000 Received: from firost (larco.ioguix.net [82.66.0.6]) by mail.dalibo.com (Postfix) with ESMTPSA id 85F72224F2; Wed, 1 Jul 2020 12:15:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1593598556; bh=q6jdVy9e3hckyIQIxB13cGZ5+1rGaILfG2L7BZu/qzM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=d4JmPUUWwLG1Tiz9xADDxxm+3GvnYUfSj+0ZB6qwyu5zSUuAKzwWf/yh/l5RkUNGV j3Aa0cL9Fy58hwg7Y7JD0Fo17hMmSXOjC/y7XBZ/mz/XwMAqU7N1gX8P1Y81/umKc5 dM4UniwPIA96bTGPT9ekuYRRc5YROSGjzew5NP6Y= Date: Wed, 1 Jul 2020 12:15:55 +0200 From: Jehan-Guillaume de Rorthais To: Kyotaro Horiguchi Cc: pgsql-hackers@lists.postgresql.org, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, andres@anarazel.de, masao.fujii@oss.nttdata.com Subject: Re: [patch] demote Message-ID: <20200701121555.4b9ee644@firost> In-Reply-To: <20200626.161438.1461210156318414119.horikyota.ntt@gmail.com> References: <20200617174451.222078b4@firost> <20200625192754.3e105cfc@firost> <20200626.161438.1461210156318414119.horikyota.ntt@gmail.com> Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 26 Jun 2020 16:14:38 +0900 (JST) Kyotaro Horiguchi wrote: > Hello. > > At Thu, 25 Jun 2020 19:27:54 +0200, Jehan-Guillaume de Rorthais > wrote in > > Here is a summary of my work during the last few days on this demote > > approach. > > > > Please, find in attachment v2-0001-Demote-PoC.patch and the comments in the > > commit message and as FIXME in code. > > > > The patch is not finished or bug-free yet, I'm still not very happy with the > > coding style, it probably lack some more code documentation, but a lot has > > changed since v1. It's still a PoC to push the discussion a bit further > > after being myself silent for some days. > > > > The patch is currently relying on a demote checkpoint. I understand a forced > > checkpoint overhead can be massive and cause major wait/downtime. But I keep > > this for a later step. Maybe we should be able to cancel a running > > checkpoint? Or leave it to its synching work but discard the result without > > wirting it to XLog? > > If we are going to dive so close to server shutdown, we can just > utilize the restart-after-crash path, which we can assume to work > reliably. The attached is a quite rough sketch, hijacking smart > shutdown path for a convenience, of that but seems working. "pg_ctl > -m s -W stop" lets server demote. This was actually my very first toy PoC. However, resetting everything is far from a graceful demote I was seeking for. Moreover, such a patch will not be able to evolve to eg. keep read only backends around. > > I hadn't time to investigate Robert's concern about shared memory for > > snapshot during recovery. > > The patch does all required clenaup of resources including shared > memory, I believe. It's enough if we don't need to keep any resources > alive? Resetting everything might not be enough. If I understand Robert's concern correctly, it might actually need more shmem for hot standby xact snapshot. Or maybe some shmem init'ed differently. Regards,