[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    restore-command error handling
From:       Sebastiaan Mannem <sebas () mannem ! nl>
Date:       2021-12-25 8:04:51
Message-ID: 7f385d14be564e5d8fecf9a3c201c8b5 () mannem ! nl
[Download RAW message or body]

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/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

> =126: Ouch, big problem. Better not proceed, but error out with a FAIL instead


Looking at https://tldp.org/LDP/abs/html/exitcodes.html exit codes beyond 125 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 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 distinguish in exit codes, but since \
all I currently can do is exit with a code >= 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 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 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.


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} \
--></style> </head>
<body dir="ltr">
<div id="divtagdefaultwrapper" \
style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" \
dir="ltr"> <p>Hi,</p>
<p><br>
</p>
<p>this should probably&nbsp;be for pgsql-hackers, but&nbsp;<a \
href="https://www.postgresql.org/list/" class="OWAAutoLink" id="LPlnk156334" \
previewremoved="true">https://www.postgresql.org/list/</a>&nbsp;mentioned '<span>You \
must try elsewhere first!', and this list&nbsp;was second  best...</span></p>
<p><br>
</p>
<p>I wanted to point you to this github issue:</p>
<p><a href="https://github.com/wal-g/wal-g/issues/1126" class="OWAAutoLink" \
id="LPlnk503201" previewremoved="true">https://github.com/wal-g/wal-g/issues/1126</a><br>
 </p>
<p><br>
</p>
<p>Basically, Postgres only knows of 3 types of return codes:</p>
<p>0: No problem, next WAL file...</p>
<p>1 - 125: End of timeline? Ok, lets stop recovery and go online</p>
<p>&gt;=126: Ouch, big problem. Better&nbsp;not proceed, but error out with a FAIL \
instead</p> <p><br>
</p>
<p>Looking at&nbsp;<a href="https://tldp.org/LDP/abs/html/exitcodes.html" \
class="OWAAutoLink" id="LPlnk55151" \
previewremoved="true">https://tldp.org/LDP/abs/html/exitcodes.html</a>&nbsp;exit \
codes beyond&nbsp;125 is all OS related.</p> <p><span style="font-size: 12pt;">Like \
'</span><span style="font-size: 12pt;">Permission problem or command is not an \
executable</span><span style="font-size: 12pt;">',&nbsp;</span><span \
style="font-size: 12pt;">or '</span><span style="font-size: 12pt;">Control-C  is \
fatal error signal 2</span><span style="font-size: 12pt;">'.</span></p> <p><br>
</p>
<p>I would assume that exit&nbsp;code 78 would be a better choice to distinguish \
errors&nbsp;<span style="font-size: 12pt;">for the restore_command which are not \
os-related, b</span><span style="font-size: 12pt;">ut still would be better ending \
in&nbsp;</span><span style="font-size: 12pt;">'</span><span style="font-size: \
12pt;">Ouch,  big problem.&nbsp;</span><span style="font-size: 12pt;">Better&nbsp;not \
proceed, but error out with a FAIL instead'.</span></p> <p><span style="font-family: \
Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, &quot;Apple Color Emoji&quot;, \
&quot;Segoe UI Emoji&quot;, NotoColorEmoji, &quot;Segoe UI Symbol&quot;, \
&quot;Android Emoji&quot;, EmojiSymbols; font-size: 16px;"></span></p> <p><span \
style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, &quot;Apple \
Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, &quot;Segoe UI \
Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: 16px;"><br> \
</span></p> <p><span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, \
EmojiFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, \
&quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: \
16px;">I think I will work on a fix for wal-g to better distinguish  in exit \
codes,&nbsp;</span>but since all I currently can do&nbsp;is exit with a code &gt;= \
126,&nbsp;I wanted to bring this to the postgres community too.</p> <p>Furthermore, \
this is&nbsp;<span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, \
EmojiFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, \
&quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: \
16px;">beyond wal-g, basically for everything  that runs as a \
restore_command...</span></p> <p><span style="font-family: Calibri, Helvetica, \
sans-serif, Helvetica, EmojiFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI \
Emoji&quot;, NotoColorEmoji, &quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, \
EmojiSymbols; font-size: 16px;">Would you consider another exit code to the list so  \
that restore_commands&nbsp;</span>don't need to exit with error codes that where \
meant to signal OS-level issues?</p> <p><span style="font-family: Calibri, Helvetica, \
sans-serif, Helvetica, EmojiFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI \
Emoji&quot;, NotoColorEmoji, &quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, \
EmojiSymbols; font-size: 16px;"><br> </span></p>
<p><span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, \
&quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, \
&quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: \
16px;">I wanted to end with this quote from the second link  I pointed to:</span></p>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<p><span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, \
&quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, \
&quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: \
16px;"><span>Ending a script with exit 127 would certainly  cause confusion when \
troubleshooting (is the error code a &quot;command not found&quot; or a user-defined \
one?).</span></span></p> <p><span style="font-family: Calibri, Helvetica, sans-serif, \
Helvetica, EmojiFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, \
NotoColorEmoji, &quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; \
font-size: 16px;"><span>However, many scripts use an exit 1 as a general  \
bailout-upon-error.&nbsp;</span></span></p> <p><span style="font-family: Calibri, \
Helvetica, sans-serif, Helvetica, EmojiFont, &quot;Apple Color Emoji&quot;, \
&quot;Segoe UI Emoji&quot;, NotoColorEmoji, &quot;Segoe UI Symbol&quot;, \
&quot;Android Emoji&quot;, EmojiSymbols; font-size: 16px;"><span>Since exit code 1 \
signifies so many possible  errors, it is not particularly useful in \
debugging.</span><br> </span></p>
</blockquote>
<p><span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, \
&quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, \
&quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: \
16px;">Which to me is not just for 127, but for all exit codes  \
beyond&nbsp;125...</span></p> <p><span style="font-family: Calibri, Helvetica, \
sans-serif, Helvetica, EmojiFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI \
Emoji&quot;, NotoColorEmoji, &quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, \
EmojiSymbols; font-size: 16px;"><br> </span></p>
<p><span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, \
&quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, \
&quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: \
16px;">Thanks.</span></p> </div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic