Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fXgYz-00059g-Jl for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Jun 2018 05:30:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fXgYx-0004OH-Px for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Jun 2018 05:30:47 +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.89) (envelope-from ) id 1fXgYx-0004OA-Fq for pgsql-hackers@lists.postgresql.org; Tue, 26 Jun 2018 05:30:47 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fXgYq-0004Bq-CN for pgsql-hackers@postgresql.org; Tue, 26 Jun 2018 05:30:46 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C6CC421E79; Tue, 26 Jun 2018 01:30:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 26 Jun 2018 01:30:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=XBK5uR+VbnK4910PQeQmsZBHtdVahdn97JOvna5ZSv8=; b=WaL+T/q1 NBXnYUcMt25xk5w/QInKN/Yel6YBL4hf4TAb3KFEPDt9a9ky6PMTx3OUTNvQEEUV gGr1k0vw1+Sa03fWDWy5Lwp1apmGzqn1WJH0j9PN9ariN3rE2MFhEupZ2Kvm42Wj 3WZIdgFe2FpB3vjB0IEc6zpcsDzOW6LiEFtabMk5fIkax2KiVxGqXnAvdpXunAaY tHlEyFLAxANUCLMYQ7aPOIAyjLm0SOkRfgfNFFvQEjV28xGpnHeG22ewdZRYlgIq XlBG8GcN78Mryh+0WQMaEeV5SQz/QiCmUk1n4s+ENBt0rwbCXItKAdLnDKxGDfjs 1kMgDZHgMW7YgA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=XBK5uR+VbnK4910PQeQmsZBHtdVah dn97JOvna5ZSv8=; b=jE/uQvkt4iGLi6HoulTlS3MOWW3hpkCwEzx9diiFpyXJF ml66mePioPCtjox8cOajROFQeDr3s7Y51fHBUIjyLEDvZEMekkNnD53OvOam+ZC1 z9olOymHqQ6O5uT7n7gcUydyG/drw3tMML4bxcdDk3VLJZZ0fiQL6+XNRzScwAdJ wwoSIqFIW9GKxAAF9jpmMGeJ9/WTRBLxfhFLWaiM/7rBQGj+r3oUzpWDjsCqKRJd I6tLGpZ0VhNrU5s+VyE2ml5M77EXAt0bjDp7UJVlsjs+FiEYuJcvwe/Mkr7mudAW vcFU5bM3rre36gPJZst9q7lm0nGu3RG5I7eRGja8Q== X-ME-Proxy: X-ME-Sender: Received: from paquier.xyz (mp76f1fa50.ap.nuro.jp [118.241.250.80]) by mail.messagingengine.com (Postfix) with ESMTPA id 81B1FE451A; Tue, 26 Jun 2018 01:30:38 -0400 (EDT) Date: Tue, 26 Jun 2018 14:30:35 +0900 From: Michael Paquier To: "Yotsunaga, Naoki" Cc: Postgres hackers Subject: Re: automatic restore point Message-ID: <20180626053035.GD31353@paquier.xyz> References: <8E9126CB6CE2CD42962059AB0FBF7B0DBE3167@g01jpexmbkw23> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vmttodhTwj0NAgWp" Content-Disposition: inline In-Reply-To: <8E9126CB6CE2CD42962059AB0FBF7B0DBE3167@g01jpexmbkw23> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --vmttodhTwj0NAgWp Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 26, 2018 at 01:17:31AM +0000, Yotsunaga, Naoki wrote: > The following is a description of "automatic restore point". > =E3=80=90Background=E3=80=91 > When DBA's operation failure, for example DBA accidently drop table, > the database is restored from the file system backup and recovered by > using time or transaction ID. The transaction ID is identified from > WAL. > =20 > In order to solve the above problem,=20 > I'd like propose a feature to implement automatic recording function > of recovery point. There is also recovery_target_lsn which is new as of v10. This parameter is way better than having to track down time or XID, which is a reason why I developped it. Please note that this is also one of the reasons why it is possible to delay WAL replays on standbys, so as an operator has room to fix such operator errors. Having of course cold backups with a proper WAL archive and a correct retention policy never hurts. > =E3=80=90Setting file=E3=80=91 > Set postgres.conf. > auto_create_restore_point =3D on # Switch on/off automatic recording > function of recovery point. The default value is 'off'. >=20 > So what do you think about it? Do you think is it useful? So basically what you are looking for here is a way to enforce a restore point to be created depending on a set of pre-defined conditions? How would you define and choose those? > Also, when recovering with the current specification, tables other > than the returned table also return to the state of the specified > recovery point. > So, I=E2=80=99m looking for ways to recover only specific tables. Do you = have > any ideas?=20 Why not using the utility hook which filters out for commands you'd like to forbid, in this case TRUNCATE or a DROP TABLE on a given relation? Or why not simply using an event trigger at your application level so as you can actually *prevent* the error to happen first? With the last option you don't have to write C code, but this would not filter TRUNCATE. In short, what you propose looks over-complicated to me and there are options on the table which allow the problem you are trying to solve to not happen at all. You could also use the utility hook to log or register somewhere hte XID/time/LSN associated to a given command and then use it as your restore point. This could also happen out of core. -- Michael --vmttodhTwj0NAgWp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlsxz3sACgkQnvQgOdby QH3Geg//Z72GIHxcUqjYpEd01T/v2kLzmj+yqO2WX3B3oVOGtHzrjDklc2f2ADX0 FU1fJaUgtoj6iKdO7IjRHLwqqRKLWp7GLDAmP2vWGB2VIFC0fDzoP8RbnTgpmeQK ZuCZ/Nl2rgYMqLdkUdpu2k7911rHDXM9hG70EPbdm1tY92SWGT4i7CPR01QTyGLn 8KKCVKaEZc7HHwM7+4P/MpZ+kax0gM/UFT28TMh8D1+HVlPILhWLsKdyuXkJbu7l cGEAcN9we6b/n9QVBcOh+ewoOhbic0lIp79mGrZh/tNgg5Op7Rwm3R8FWdR3Mb6e RJ0l5wMPzvzC6q0gpU4V4wGYPE1YWi0WFSua+87vaWSCg1kXby/mnB+YMQYYE4Av Ca6pBgbutRG37JBTW01i9iIO1hfJEXAvbvJwp/jkaiGL4alYJmdGPmWiYDxgClDv TRFq2/XJ1xyUQ1kMu0OBBXwV///2WdFVnn1c1OOKdSpTF+Y4ul+0jXiv+oMtH0/x tyoLACeZbIdL/qlSbfAxv3R/XNp9MaIIJh8qcneoUwuG3FaCMiZXV29J/G8O44UC JAB9/MxfzaX3OGMmgPCVu0BBbGlov4uHj+pLg2gfTqLMaOCoidfeYewYPBKiGqET cmWYHm3q4F8LjnV9FT4jQelwQSQMEZhg+66W3iqEXmxXB/eQpyI= =RMyU -----END PGP SIGNATURE----- --vmttodhTwj0NAgWp--