From: | Lucas Possamai <drum(dot)lucas(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: wal segment failed |
Date: | 2016-05-18 01:38:53 |
Message-ID: | CAE_gQfWRPPU4baQPySJx+tM7kNGSsxJYjsakX75cwk1BVcO-qQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On 18 May 2016 at 13:29, Alvaro Herrera <alvherre(at)2ndquadrant(dot)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 "${(at)}"; 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}(at)${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;
From | Date | Subject | |
---|---|---|---|
Next Message | Campbell, Lance | 2016-05-18 14:31:21 | Table symbolic link |
Previous Message | Alvaro Herrera | 2016-05-18 01:29:08 | Re: wal segment failed |