Обсуждение: What is "return code" for WAL send command

Поиск
Список
Период
Сортировка

What is "return code" for WAL send command

От
zhong ming wu
Дата:

Hello

I have a master PG 8.1.11 sending WAL files to a cold-standby using rsync

For some reason it failed recently with "return codes 32512" and I couldn't find this num. as a valid rsync exit code

During the time that the error was going on I tried the rsync command manually and didn't error

Can someone tell me what kind if error is 32512

Thanks

Mr. Wu

Re: What is "return code" for WAL send command

От
Tom Lane
Дата:
zhong ming wu <mr.z.m.wu@gmail.com> writes:
> I have a master PG 8.1.11 sending WAL files to a cold-standby using rsync

> For some reason it failed recently with "return codes 32512" and I couldn't
> find this num. as a valid rsync exit code

> During the time that the error was going on I tried the rsync command
> manually and didn't error

> Can someone tell me what kind if error is 32512

A more recent version of Postgres would break that down for you: it
means the subprocess exited with exit(127).  A look in the shell
man page suggests this is a "command not found" failure.  Maybe
there's something flaky about where you have rsync mounted?

            regards, tom lane

Re: What is "return code" for WAL send command

От
zhong ming wu
Дата:
On Sat, Oct 23, 2010 at 11:48 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> A more recent version of Postgres would break that down for you: it
> means the subprocess exited with exit(127).  A look in the shell
> man page suggests this is a "command not found" failure.  Maybe
> there's something flaky about where you have rsync mounted?
>
>                        regards, tom lane
>

Thanks for the reply.

postgres user has both rsync and ssh in its path but is it possible
that it is not using $PATH ?

One other thing is that just before the error the postgres was
restarted by other admin with rc.d/postgresql command
instead of pg_ctl which is what I normally use.  Perhaps
rc.d/postgresql command does not work well with WAL sending command?

But just to be on the safe side I am changing postgresql.conf with
absolute path to rsync as WAL sending command.

Re: What is "return code" for WAL send command

От
Tom Lane
Дата:
zhong ming wu <mr.z.m.wu@gmail.com> writes:
> postgres user has both rsync and ssh in its path but is it possible
> that it is not using $PATH ?

> One other thing is that just before the error the postgres was
> restarted by other admin with rc.d/postgresql command
> instead of pg_ctl which is what I normally use.  Perhaps
> rc.d/postgresql command does not work well with WAL sending command?

I'd bet that the other way failed to start the postmaster with the
expected value of $PATH.  Take a close look at the script and see
if it causes postgres' login environment to be installed or not
(ie, su -l not just su).

            regards, tom lane

Re: What is "return code" for WAL send command

От
Fredric Fredricson
Дата:
  On 10/23/2010 02:01 PM, zhong ming wu wrote:
>
> Hello
>
> I have a master PG 8.1.11 sending WAL files to a cold-standby using rsync
>
> For some reason it failed recently with "return codes 32512" and I
> couldn't find this num. as a valid rsync exit code
>
> During the time that the error was going on I tried the rsync command
> manually and didn't error
>
I guess you have fallen into the common pitfall that cron does not read
bash ini files and does not set the $PATH variable. If you want your
scripts to be run by cron you must make them independent of $PATH and
other variables set by .bashrc etc.

My $.02.
/Fredric
>
> Can someone tell me what kind if error is 32512
>
> Thanks
>
> Mr. Wu
>


Вложения

Re: What is "return code" for WAL send command

От
David W Noon
Дата:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 25 Oct 2010 09:49:02 +0200, Fredric Fredricson wrote abour Re:
[GENERAL] What is "return code" for WAL send command:

>  On 10/23/2010 02:01 PM, zhong ming wu wrote:
[snip]
>> For some reason it failed recently with "return codes 32512" and I 
>> couldn't find this num. as a valid rsync exit code
>>
>> During the time that the error was going on I tried the rsync
>> command manually and didn't error
>>
>I guess you have fallen into the common pitfall that cron does not
>read bash ini files and does not set the $PATH variable. If you want
>your scripts to be run by cron you must make them independent of $PATH
>and other variables set by .bashrc etc.

One can also specify environment variables at the top of the crontab.
This overcomes the issue of cron jobs not reading /etc/profile and
other start-up scripts that are processed by a normal login shell.  For
example, here is my personal crontab:

# Establish environment variables.
JAVA_HOME='/etc/java-config-2/current-system-vm'

PATH="/home/dwn/bin:/usr/local/bin:/bin:/usr/bin:/opt/bin:/etc/java-config-2/current-system-vm/bin:/etc/java-config-2/current-system-vm/jre/bin"
TMPDIR='/tmp'
HOME='/home/dwn'
SHELL='/bin/zsh'
LOGNAME='dwn'
LC_ALL='en_GB.UTF-8'
http_proxy='http://webproxy.local:8080'
ftp_proxy='http://webproxy.local:8080'
RSYNC_PROXY='webproxy.local:8080'
CC='gcc'
CXX='g++'

# Set our priority level.
!nice(4)

# Each morning run a scan of our home directory for backup files.
%daily 30 20 find "$HOME/" \( -name \*~ -o -iname \*.bak \) -print
- -delete

# Clean out the work directory for Lazarus.
%daily 18 05 cd "$HOME/Lazarus_projects/tmp/" && for fn in *(N); do rm
- -rf "$fn"; done

# Clean out the cache subdirectories under $HOME.
%daily 28 07 cache_clean.zsh


As you can see, it establishes all the most common environment variables
before any cron job starts.
- -- 
Regards,

Dave  [RLU #314465]
======================================================================
dwnoon@ntlworld.com (David W Noon)
======================================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)

iEYEARECAAYFAkzFZ7QACgkQRQ2Fs59Psv/JBwCeKRUID/cE4roMbduG2I345evk
hiwAn3ohd2+2FxkVEwkeVuV/Q6eJpixd
=w68f
-----END PGP SIGNATURE-----

Re: What is "return code" for WAL send command

От
Fredric Fredricson
Дата:
  On 10/25/2010 01:19 PM, David W Noon wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Mon, 25 Oct 2010 09:49:02 +0200, Fredric Fredricson wrote abour Re:
> [GENERAL] What is "return code" for WAL send command:
>
>>   On 10/23/2010 02:01 PM, zhong ming wu wrote:
> [snip]
>>> For some reason it failed recently with "return codes 32512" and I
>>> couldn't find this num. as a valid rsync exit code
>>>
>>> During the time that the error was going on I tried the rsync
>>> command manually and didn't error
>>>
>> I guess you have fallen into the common pitfall that cron does not
>> read bash ini files and does not set the $PATH variable. If you want
>> your scripts to be run by cron you must make them independent of $PATH
>> and other variables set by .bashrc etc.
> One can also specify environment variables at the top of the crontab.
> This overcomes the issue of cron jobs not reading /etc/profile and
> other start-up scripts that are processed by a normal login shell.  For
> example, here is my personal crontab:
Ah, yes of course, It was a while ago I played with cron.
"man 5 crontab" is also a good command to know, or
"info crontab" if you prefer those modern inventions.

/Fredric


Вложения

Re: What is "return code" for WAL send command

От
zhong ming wu
Дата:
On Mon, Oct 25, 2010 at 1:58 PM, Fredric Fredricson
<Fredric.Fredricson@bonetmail.com> wrote:
>  On 10/25/2010 01:19 PM, David W Noon wrote:
>>
> Ah, yes of course, It was a while ago I played with cron.
> "man 5 crontab" is also a good command to know, or
> "info crontab" if you prefer those modern inventions.
>

This is nothing to do with cron since postgresql is started manually.

Also no mention is made of cron in my original post.