Re: wal segment failed - Mailing list pgsql-admin

From Lucas Possamai
Subject Re: wal segment failed
Date
Msg-id CAE_gQfWRPPU4baQPySJx+tM7kNGSsxJYjsakX75cwk1BVcO-qQ@mail.gmail.com
Whole thread Raw
In response to Re: wal segment failed  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-admin


On 18 May 2016 at 13:29, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
Lucas Possamai wrote:

> archive command:
>
> archive_command = 'exec nice -n 19 ionice -c 2 -n 7
> ../../bin/archive_command.ssh_to_slaves.bash "%p" prod-db-01 prod-db-02
> localhost:30022'

So what is in ../../bin/archive_command.ssh_to_slaves.bash?  Why are
you using "exec"?


we send all the wal files through that script


# we open the file from here

exec {WAL_LOCK_FD}>"${WAL_SEGMENT}.ac_lock" || exit 4;
if ! flock -n ${WAL_LOCK_FD}; then
printf 'Cannot acquire lock for WAL segment `%s`. Aborting\n' "${WAL_SEGMENT}" 1>&2;
exit 4;
fi;

# time to connect and send the wal segments to all hosts. We count the failed transfers
TRANSFER_ERRORS=0;
ARORD=0; # see above
for NEXT_PAIR in "${@}"; do
if [ $((ARORD++)) -gt 0 ]; then
NEXT_HOST="${NEXT_PAIR%:*}";
if [[ "${NEXT_PAIR}" =~ : ]]; then NEXT_PORT=${NEXT_PAIR#*:}; else NEXT_PORT=22; fi;
# we use tar over SSH as I don't fully trust scp's exit status. The added benefit is that tar preserves all attributes
# the downside is that it's a little tricky to make the remote path relative
#printf 'Attempting to archive WAL segment `%s` on host `%s`\n' "${WAL_SEGMENT}" "${NEXT_PAIR}" 1>&2;
IFS=':';
set +e;
tar -c -O --no-same-owner -C "${WAL_SEGMENT%/*}" "${WAL_SEGMENT##*/}" | ssh -p ${NEXT_PORT} -C -o 'BatchMode=yes' -o 'CompressionLevel=3' "${USER}@${NEXT_HOST}" "exec tar -x --no-same-owner --overwrite -C '${WAL_ARCHIVE_PATH}'";
PS_CONCAT="${PIPESTATUS[*]}";
set -e;
IFS="${DEFAULT_IFS}";
if [ "${PS_CONCAT}" == '0:0' ]; then
printf 'WAL segment `%s` successfully archived on host `%s`\n' "${WAL_SEGMENT}" "${NEXT_PAIR}" 1>&2;
else
: $((TRANSFER_ERRORS++));
printf 'Failed to archive WAL segment `%s` on host `%s`\n' "${WAL_SEGMENT}" "${NEXT_PAIR}" 1>&2;
fi;
fi;
done;
flock -u ${WAL_LOCK_FD};
exec {WAL_LOCK_FD}<&-;
rm "${WAL_SEGMENT}.ac_lock";
if [ ${TRANSFER_ERRORS} -eq 0 ]; then
exit 0;
else
exit 4;

pgsql-admin by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: wal segment failed
Next
From: "Campbell, Lance"
Date:
Subject: Table symbolic link