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 1n1235-0003Ux-Cq for pgsql-general@arkaria.postgresql.org; Sat, 25 Dec 2021 08:05:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n1231-00087B-Ve for pgsql-general@arkaria.postgresql.org; Sat, 25 Dec 2021 08:04:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n1231-000872-HJ for pgsql-general@lists.postgresql.org; Sat, 25 Dec 2021 08:04:59 +0000 Received: from smtpout1.mo3004.mail-out.ovh.net ([79.137.123.219]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n122y-0004aX-Fj for pgsql-general@lists.postgresql.org; Sat, 25 Dec 2021 08:04:58 +0000 Received: from pro1.mail.ovh.net (unknown [10.108.16.48]) by mo3004.mail-out.ovh.net (Postfix) with ESMTPS id 90ACB23CF18 for ; Sat, 25 Dec 2021 08:04:52 +0000 (UTC) Received: from DAG17EX1.emp.local (172.16.2.33) by DAG17EX2.emp.local (172.16.2.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.17; Sat, 25 Dec 2021 09:04:51 +0100 Received: from DAG17EX1.emp.local ([fe80::4161:9994:6b99:2eeb]) by DAG17EX1.emp.local ([fe80::4161:9994:6b99:2eeb%5]) with mapi id 15.01.2375.017; Sat, 25 Dec 2021 09:04:51 +0100 From: Sebastiaan Mannem To: pgsql-general list Subject: restore-command error handling Thread-Topic: restore-command error handling Thread-Index: AQHX+WLwzPO/tkXUhEOxgLGruuFgVQ== Date: Sat, 25 Dec 2021 08:04:51 +0000 Message-ID: <7f385d14be564e5d8fecf9a3c201c8b5@mannem.nl> Accept-Language: nl-NL, en-US Content-Language: nl-NL X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [86.81.225.122] Content-Type: multipart/alternative; boundary="_000_7f385d14be564e5d8fecf9a3c201c8b5mannemnl_" MIME-Version: 1.0 X-Ovh-Tracer-Id: 15034141457423028185 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvuddrudduuddgudduhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffuthffkfhitgggsegrtdhjredttddunecuhfhrohhmpefuvggsrghsthhirggrnhcuofgrnhhnvghmuceoshgvsggrshesmhgrnhhnvghmrdhnlheqnecuggftrfgrthhtvghrnhepueeuieevgefgteeijeeutdfhheetheeufedviedvfffghfeutdejgfdtieeggeehnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghdpghhithhhuhgsrdgtohhmpdhtlhguphdrohhrghenucfkpheptddrtddrtddrtddpkeeirdekuddrvddvhedruddvvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhhtpdhhvghlohepphhrohdurdhmrghilhdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepshgvsggrshesmhgrnhhnvghmrdhnlhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_7f385d14be564e5d8fecf9a3c201c8b5mannemnl_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, this should probably be for pgsql-hackers, but https://www.postgresql.org/l= ist/ mentioned 'You must try elsewhere first!', and this list was second be= st... I wanted to point you to this github issue: https://github.com/wal-g/wal-g/issues/1126 Basically, Postgres only knows of 3 types of return codes: 0: No problem, next WAL file... 1 - 125: End of timeline? Ok, lets stop recovery and go online >=3D126: Ouch, big problem. Better not proceed, but error out with a FAIL i= nstead Looking at https://tldp.org/LDP/abs/html/exitcodes.html exit codes beyond 1= 25 is all OS related. Like 'Permission problem or command is not an executable', or 'Control-C is= fatal error signal 2'. I would assume that exit code 78 would be a better choice to distinguish er= rors for the restore_command which are not os-related, but still would be b= etter ending in 'Ouch, big problem. Better not proceed, but error out with = a FAIL instead'. I think I will work on a fix for wal-g to better distinguish in exit codes,= but since all I currently can do is exit with a code >=3D 126, I wanted to= bring this to the postgres community too. Furthermore, this is beyond wal-g, basically for everything that runs as a = restore_command... Would you consider another exit code to the list so that restore_commands d= on't need to exit with error codes that where meant to signal OS-level issu= es? I wanted to end with this quote from the second link I pointed to: Ending a script with exit 127 would certainly cause confusion when troubles= hooting (is the error code a "command not found" or a user-defined one?). However, many scripts use an exit 1 as a general bailout-upon-error. Since exit code 1 signifies so many possible errors, it is not particularly= useful in debugging. Which to me is not just for 127, but for all exit codes beyond 125... Thanks. --_000_7f385d14be564e5d8fecf9a3c201c8b5mannemnl_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi,


this should probably be for pgsql-hackers, but https://www.postgresql.org/list/ mentioned 'You must try elsewhere first!', and this list was second best...


I wanted to point you to this github issue:

https://github.com/wal-g/wa= l-g/issues/1126


Basically, Postgres only knows of 3 types of return codes:

0: No problem, next WAL file...

1 - 125: End of timeline? Ok, lets stop recovery and go online

>=3D126: Ouch, big problem. Better not proceed, but error out wi= th a FAIL instead


Looking at https://tl= dp.org/LDP/abs/html/exitcodes.html exit codes beyond 125 is a= ll OS related.

Like 'Permission problem or command is not an executable', or '<= /span>Control-C is fatal error signal 2'.


I would assume that exit code 78 would be a better choice to distin= guish errors for the restore_command = which are not os-related, but still= would be better ending in 'Ouch, big problem. Better not = proceed, but error out with a FAIL instead'.


I think I will work on a fix for wal-g to better dis= tinguish in exit codes, but since all I currently can do is exit w= ith a code >=3D 126, I wanted to bring this to the postgres communi= ty too.

Furthermore, this is beyond wal-g, basically fo= r everything that runs as a restore_command...

Would you consider another exit code to the list so that restore_commands don't need to exit with error codes that= where meant to signal OS-level issues?


I wanted to end with this quote from the second link I pointed to:

Ending a script with exit 127 would certainly cause confusion when troubleshooting (is the error code a "command no= t found" or a user-defined one?).

However, many scripts use an exit 1 as a gener= al bailout-upon-error. 

Since exit code 1 signifies so many possible errors, it is not particularly useful in debugging.

Which to me is not just for 127, but for all exit co= des beyond 125...


Thanks.

--_000_7f385d14be564e5d8fecf9a3c201c8b5mannemnl_--