Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WA0ME-0007GD-Bi for pgsql-admin@arkaria.postgresql.org; Sun, 02 Feb 2014 16:57:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WA0MD-0002ZZ-Kn for pgsql-admin@arkaria.postgresql.org; Sun, 02 Feb 2014 16:57:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WA0MC-0002ZT-P6 for pgsql-admin@postgresql.org; Sun, 02 Feb 2014 16:57:20 +0000 Received: from mail-ig0-f171.google.com ([209.85.213.171]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WA0M9-0002VG-K0 for pgsql-admin@postgresql.org; Sun, 02 Feb 2014 16:57:20 +0000 Received: by mail-ig0-f171.google.com with SMTP id uy17so2767604igb.4 for ; Sun, 02 Feb 2014 08:57:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=9DtFuueFFU5m2VKItXsTgoPfyicEA4OQ6rRdka62QJw=; b=PdQi6C7KFUNlqivcLK0Znn/DkM1ND10h1f2s1z0CvYReYmT0lSl0lRktpnm0Vh2Ezz BHxBUcq6ybfCWXStXt0e75Z96Mu8hoU0rMA7N2cG029cRoMbEa8kUz739ro/dhVoqRLX FEfCzhdiTrJf3M1F86Opd7A4pAsqstgMtRXZxYoXiERQdFUvNvx6z4l5owcSh6RkpMN8 uBY97ZK2W4MBuyPNCy49cK/l+CEw+L6Sw4R2lC0tu2bMGIpn5a0P6qACRLUVMV0RWBKP CRgIZWrL/7J5XFh0TYQLqjdnqGexaAbP3uX1S1wX1/XHh+kdxkj37TlndYuiaChIAq9q 6L6A== X-Gm-Message-State: ALoCoQkiY4vnQVVqa6eWD4M6V+LCSo4PZoxkkCuiN61lUSB3b0IVZV2FSvYAS9HC5Ms5GREOW4CC X-Received: by 10.50.154.102 with SMTP id vn6mr8153232igb.15.1391360236025; Sun, 02 Feb 2014 08:57:16 -0800 (PST) Received: from Kevins-MacBook-Pro.local ([67.148.186.194]) by mx.google.com with ESMTPSA id kb10sm21014499igb.6.2014.02.02.08.57.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Feb 2014 08:57:15 -0800 (PST) Message-ID: <52EE78EA.7070801@consistentstate.com> Date: Sun, 02 Feb 2014 09:57:14 -0700 From: CS DBA User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Raghavendra CC: pgsql-admin Subject: Re: Cannot change archive_command with a reload References: <52EE69AF.4030709@consistentstate.com> <52EE71B9.3090204@consistentstate.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------090401090005000107020409" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org This is a multi-part message in MIME format. --------------090401090005000107020409 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 2/2/14, 9:51 AM, Raghavendra wrote: > > On Sun, Feb 2, 2014 at 9:56 PM, CS DBA > wrote: > > On 2/2/14, 9:19 AM, Raghavendra wrote: >> >> >> On Sun, Feb 2, 2014 at 9:22 PM, CS DBA >> > >> wrote: >> >> Hi all; >> >> we have a cluster running with an archive command that is >> failing. >> I tried a reload and the value does not change >> >> >> Reload with new value won't work until you fix the failing >> archive_command. >> >> Eg:- >> >> ps -ef | grep arch >> postgres 29743 29736 0 Jan30 ? 00:00:00 postgres: >> archiver process failed on 00000001000000010000003D >> >> and it might cause same error you are experiencing as >> >> postgres=# select set_config('archive_command','cp %p >> /opt/PostgreSQL/9.3/a93/%f',false); >> ERROR: parameter "archive_command" cannot be changed now >> >> So, fix the archive_command first and then give new changes. >> >> Tried a set_config and I get this error: >> >> select set_config ('archive_command', 'cp %p /data/wal_tmp/%f >> && mv /data/wal_tmp/%f /data/wal/&f', 'false'); >> ERROR: parameter "archive_command" cannot be changed now >> >> >> If your archive_command pointing to "/data/wal_tmp" then please >> ensure that directory exists there. If that directory not present >> then archive process fail to copy the transaction logs. When >> archiver process in failed state you cannot apply any new changes >> to the archive_command it will fail. >> >> Also, am surprised to see "mv" command, basically the >> archive_command meant to have a copies of pg_xlogs but not any OS >> related directory movements. > > we want to copy the file to /data/wal_tmp, then do a mv to > /data/wal so our process that ships a copy to the standby servers > never see's a partial file (since it watches /data/wal) > > > 'cp %p /data/wal_tmp/%f && mv /data/wal_tmp/%f /data/wal/&f', > > Seems you are missing something here, you have two action commands in > your archive_command. One is copy "cp" and another is "mv" move. Once > you are copying file to the directory you are moving that entire > directory and not keeping the place available for archiver process to > copy next file in that location on its next arrival. > > Because, every transaction logs first go to archive directory as you > mentioned "cp %p /data/wal_tmp/%f". Next it will execute the other > command too since its one command string, i.e, move "mv > /data/wal_tmp/%f /data/wal&f". > > Hence, you need to have unique place for archives and it should not be > disturbed in any case. If you want to ship a copy to standby server > then have another directory with same set of copies at OS level. > > --Raghav > My issue is the &f instead of %f at the end. However here's the intent: if the first command is true (cp %p /data/wal_tmp/%f) then I want the second command to execute (mv /data/wal_tmp/%f /data/wal/%f) since both directories are in the same file system the mv is immediate so any process watching for files to show up in /data/wal will never see a partial file --------------090401090005000107020409 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 2/2/14, 9:51 AM, Raghavendra wrote:

On Sun, Feb 2, 2014 at 9:56 PM, CS DBA <cs_dba@consistentstate.com> wrote:
On 2/2/14, 9:19 AM, Raghavendra wrote:


On Sun, Feb 2, 2014 at 9:22 PM, CS DBA <cs_dba@consistentstate.com> wrote:
Hi all;

we have a cluster running with an archive command that is failing.
I tried a reload and the value does not change


Reload with new value won't work until you fix the failing archive_command.

Eg:-

ps -ef | grep arch
postgres 29743 29736  0 Jan30 ?        00:00:00 postgres: archiver process   failed on 00000001000000010000003D

and it might cause same error you are experiencing as 

postgres=# select set_config('archive_command','cp %p /opt/PostgreSQL/9.3/a93/%f',false);
ERROR:  parameter "archive_command" cannot be changed now

So, fix the archive_command first and then give new changes.

Tried a set_config and I get this error:

select set_config ('archive_command', 'cp %p /data/wal_tmp/%f && mv /data/wal_tmp/%f /data/wal/&f', 'false');
ERROR:  parameter "archive_command" cannot be changed now


If your archive_command pointing to "/data/wal_tmp" then please ensure that directory exists there. If that directory not present then archive process fail to copy the transaction logs. When archiver process in failed state you cannot apply any new changes to the archive_command it will fail. 

Also, am surprised to see "mv" command, basically the archive_command meant to have a copies of pg_xlogs but not any OS related directory movements.

we want to copy the file to /data/wal_tmp, then do a mv to /data/wal so our process that ships a copy to the standby servers never see's a partial file (since it watches /data/wal)

'cp %p /data/wal_tmp/%f && mv /data/wal_tmp/%f /data/wal/&f',

Seems you are missing something here, you have two action commands in your archive_command. One is copy "cp" and another is "mv" move. Once you are copying file to the directory you are moving that entire directory and not keeping the place available for archiver process to copy next file in that location on its next arrival.

Because, every transaction logs first go to archive directory as you mentioned "cp %p /data/wal_tmp/%f". Next it will execute the other command too since its one command string, i.e, move "mv /data/wal_tmp/%f /data/wal&f".

Hence, you need to have unique place for archives and it should not be disturbed in any case. If you want to ship a copy to standby server then have another directory with same set of copies at OS level.

--Raghav

My issue is the &f instead of %f at the end.  However here's the intent:

if the first command is true (cp %p /data/wal_tmp/%f) then I want the second command to execute (mv /data/wal_tmp/%f /data/wal/%f)

since both directories are in the same file system the mv is immediate so any process watching for files to show up in /data/wal will never see a partial file


--------------090401090005000107020409--