Re: ALTER SYSTEM SET typos and fix for temporary file name management

Lists: pgsql-hackers
From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-18 14:29:02
Message-ID: CAB7nPqQ7RdVgJac7Dgv6B_GQs+H8VA51q1RQS3DEWM+463fbOQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all,

After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I
noticed a couple of typo mistakes as well as (I think) a weird way of
using the temporary auto-configuration name postgresql.auto.conf.temp
in two different places, resulting in the patch attached.

It might be an overkill to use a dedicated variable for the temporary
autoconfiguration file (here PG_AUTOCONF_FILENAME_TEMP), but I found
kind of weird the way things are currently done on master branch. IMO,
it would reduce bug possibilities to have everything managed with a
single variable.

Typos at least should be fixed :)
Regards,
--
Michael

Attachment Content-Type Size
20140118_alter_system_fix.patch text/x-diff 4.5 KB

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-20 05:12:57
Message-ID: CAA4eK1LLDFvPBJ5nVjha1mO=RoeOwk_3eQ08WXo4tkvXbnry0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Jan 18, 2014 at 7:59 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> Hi all,
>
> After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I
> noticed a couple of typo mistakes as well as (I think) a weird way of
> using the temporary auto-configuration name postgresql.auto.conf.temp
> in two different places, resulting in the patch attached.

.tmp suffix is used at couple other places in code as well.
snapmgr.c
XactExportFilePath(pathtmp, topXid, list_length(exportedSnapshots), ".tmp");
receivelog.c
snprintf(tmppath, MAXPGPATH, "%s.tmp", path);

Although similar suffix is used at other places, but still I think it might be
better to define for current case as here prefix (postgresql.auto.conf) is also
fixed and chances of getting it changed are less. However even if we don't
do, it might be okay as we are using such suffixes at other places as well.

> It might be an overkill to use a dedicated variable for the temporary
> autoconfiguration file (here PG_AUTOCONF_FILENAME_TEMP), but I found
> kind of weird the way things are currently done on master branch. IMO,
> it would reduce bug possibilities to have everything managed with a
> single variable.
>
> Typos at least should be fixed :)

- appendStringInfoString(&buf, "# Do not edit this file manually! \n");
- appendStringInfoString(&buf, "# It will be overwritten by ALTER
SYSTEM command. \n");
+ appendStringInfoString(&buf, "# Do not edit this file manually!\n");
+ appendStringInfoString(&buf, "# It will be overwritten by ALTER
SYSTEM command.\n");

Same change in initdb.c is missing.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-21 12:47:31
Message-ID: CAB7nPqTxeENk+dz_16PBnEZOaDKKrAiR1Pb_WY4EtPYy--JjGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 20, 2014 at 2:12 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> On Sat, Jan 18, 2014 at 7:59 PM, Michael Paquier
> <michael(dot)paquier(at)gmail(dot)com> wrote:
>> Hi all,
>>
>> After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I
>> noticed a couple of typo mistakes as well as (I think) a weird way of
>> using the temporary auto-configuration name postgresql.auto.conf.temp
>> in two different places, resulting in the patch attached.
>
> .tmp suffix is used at couple other places in code as well.
> snapmgr.c
> XactExportFilePath(pathtmp, topXid, list_length(exportedSnapshots), ".tmp");
> receivelog.c
> snprintf(tmppath, MAXPGPATH, "%s.tmp", path);
>
> Although similar suffix is used at other places, but still I think it might be
> better to define for current case as here prefix (postgresql.auto.conf) is also
> fixed and chances of getting it changed are less. However even if we don't
> do, it might be okay as we are using such suffixes at other places as well.
In the case of snapmgr.c and receivelog.c, the operations are kept
local, so it does not matter much if this way of naming is done as all
the operations for a temporary file are kept within the same, isolated
function. However, the case of postgresql.auto.conf.temp is different:
this temporary file name is used as well for a check in basebackup.c,
so I imagine that it would be better to centralize this information in
a single place. Now this name is only used in two places, but who
knows if some additional checks here are there won't be needed for
this temp file...
postgresql.auto.conf.temp is also located at the root of PGDATA, so it
might be surprising for the user to find it even if there are few
chances that it can happen.

>> It might be an overkill to use a dedicated variable for the temporary
>> autoconfiguration file (here PG_AUTOCONF_FILENAME_TEMP), but I found
>> kind of weird the way things are currently done on master branch. IMO,
>> it would reduce bug possibilities to have everything managed with a
>> single variable.
>>
>> Typos at least should be fixed :)
>
> - appendStringInfoString(&buf, "# Do not edit this file manually! \n");
> - appendStringInfoString(&buf, "# It will be overwritten by ALTER
> SYSTEM command. \n");
> + appendStringInfoString(&buf, "# Do not edit this file manually!\n");
> + appendStringInfoString(&buf, "# It will be overwritten by ALTER
> SYSTEM command.\n");
>
> Same change in initdb.c is missing.
Thanks, I missed it.
--
Michael

Attachment Content-Type Size
20140121_alter_system_fix_v2.patch text/x-diff 5.2 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-21 19:45:54
Message-ID: CA+TgmoYqwOZ_nDVc6apWqBNvDVrLJ+htpmeb4JVw=fgJ3bPYWA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jan 21, 2014 at 7:47 AM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
>>> After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I
>>> noticed a couple of typo mistakes as well as (I think) a weird way of
>>> using the temporary auto-configuration name postgresql.auto.conf.temp
>>> in two different places, resulting in the patch attached.
>>
>> .tmp suffix is used at couple other places in code as well.
>> snapmgr.c
>> XactExportFilePath(pathtmp, topXid, list_length(exportedSnapshots), ".tmp");
>> receivelog.c
>> snprintf(tmppath, MAXPGPATH, "%s.tmp", path);
>>
>> Although similar suffix is used at other places, but still I think it might be
>> better to define for current case as here prefix (postgresql.auto.conf) is also
>> fixed and chances of getting it changed are less. However even if we don't
>> do, it might be okay as we are using such suffixes at other places as well.
> In the case of snapmgr.c and receivelog.c, the operations are kept
> local, so it does not matter much if this way of naming is done as all
> the operations for a temporary file are kept within the same, isolated
> function. However, the case of postgresql.auto.conf.temp is different:
> this temporary file name is used as well for a check in basebackup.c,
> so I imagine that it would be better to centralize this information in
> a single place. Now this name is only used in two places, but who
> knows if some additional checks here are there won't be needed for
> this temp file...
> postgresql.auto.conf.temp is also located at the root of PGDATA, so it
> might be surprising for the user to find it even if there are few
> chances that it can happen.

I don't think there's any real reason to defined
PG_AUTOCONF_FILENAME_TEMP. pg_stat_statements just writes
PGSS_DUMP_FILE ".tmp" and that hasn't been a problem that I know of.
I do wonder why ALTER SYSTEM SET is spelling the suffix "temp" instead
of "tmp".

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-21 20:29:08
Message-ID: 20140121202908.GK10723@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas escribió:

> I don't think there's any real reason to defined
> PG_AUTOCONF_FILENAME_TEMP. pg_stat_statements just writes
> PGSS_DUMP_FILE ".tmp" and that hasn't been a problem that I know of.
> I do wonder why ALTER SYSTEM SET is spelling the suffix "temp" instead
> of "tmp".

I agree with Michael that having pg_basebackup be aware of the ".temp"
suffix is ugly; for instance if we were to fix it to ".tmp" in ALTER
SYSTEM but forgot to change pg_basebackup, the check would be
immediately broken. But on the other hand I'm not sure why it's such a
problem for pg_basebackup that it needs to be checking in the first
place -- how about we rip that out?

Perhaps the temp file needs to be in pgsql_tmp? (Do we need to worry
about cross-filesystem links if we do? I mean, do we support mounting
pgsql_tmp separately?)

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-22 00:02:39
Message-ID: CAB7nPqTbnrr5BPO37ZyXOuNiG-ab+1U5V-YkS65tWGmA0uVS5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jan 22, 2014 at 5:29 AM, Alvaro Herrera
<alvherre(at)2ndquadrant(dot)com> wrote:
> I agree with Michael that having pg_basebackup be aware of the ".temp"
> suffix is ugly; for instance if we were to fix it to ".tmp" in ALTER
> SYSTEM but forgot to change pg_basebackup, the check would be
> immediately broken. But on the other hand I'm not sure why it's such a
> problem for pg_basebackup that it needs to be checking in the first
> place -- how about we rip that out?
Coupled with the addition of a pgsql_tmp prefix to the temp
configuration file name would work, yes we could remove this check
part.

> Perhaps the temp file needs to be in pgsql_tmp? (Do we need to worry
> about cross-filesystem links if we do? I mean, do we support mounting
> pgsql_tmp separately?)
Using pgsql_tmp looks a bit weird as well, as this prefix is used only
for temporary files doing database-related operations, and ALTER
SYSTEM is not one. Doing that this would need a mention in the docs at
least:
http://www.postgresql.org/docs/devel/static/storage-file-layout.html
Thoughts?
Regards,
--
Michael


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-22 03:55:38
Message-ID: CAA4eK1KiDujT9OqTibQhXwfTgmsSKcjFmREKiquCU-hMBhvD6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jan 22, 2014 at 1:15 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Tue, Jan 21, 2014 at 7:47 AM, Michael Paquier
> <michael(dot)paquier(at)gmail(dot)com> wrote:
>>>> After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I
>>>> noticed a couple of typo mistakes as well as (I think) a weird way of
>>>> using the temporary auto-configuration name postgresql.auto.conf.temp
>>>> in two different places, resulting in the patch attached.
>>>
>>> .tmp suffix is used at couple other places in code as well.
>>> snapmgr.c
>>> XactExportFilePath(pathtmp, topXid, list_length(exportedSnapshots), ".tmp");
>>> receivelog.c
>>> snprintf(tmppath, MAXPGPATH, "%s.tmp", path);
>>>
>>> Although similar suffix is used at other places, but still I think it might be
>>> better to define for current case as here prefix (postgresql.auto.conf) is also
>>> fixed and chances of getting it changed are less. However even if we don't
>>> do, it might be okay as we are using such suffixes at other places as well.
>> In the case of snapmgr.c and receivelog.c, the operations are kept
>> local, so it does not matter much if this way of naming is done as all
>> the operations for a temporary file are kept within the same, isolated
>> function. However, the case of postgresql.auto.conf.temp is different:
>> this temporary file name is used as well for a check in basebackup.c,
>> so I imagine that it would be better to centralize this information in
>> a single place. Now this name is only used in two places, but who
>> knows if some additional checks here are there won't be needed for
>> this temp file...
>> postgresql.auto.conf.temp is also located at the root of PGDATA, so it
>> might be surprising for the user to find it even if there are few
>> chances that it can happen.
>
> I don't think there's any real reason to defined
> PG_AUTOCONF_FILENAME_TEMP. pg_stat_statements just writes
> PGSS_DUMP_FILE ".tmp" and that hasn't been a problem that I know of.
> I do wonder why ALTER SYSTEM SET is spelling the suffix "temp" instead
> of "tmp".

+1 for changing '.temp' to '.tmp'.
I think its bit arguable whether to change it to define or not (different people
can have different opinion on this matter), but certainly changing it to .tmp
is an improvement, as we use .tmp at other places as well.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-22 14:15:01
Message-ID: CA+Tgmob4fp7B2ZS7T49v0++7ss3UhFQNA=U-VuL=EHDNeC2s1A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jan 21, 2014 at 7:02 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> On Wed, Jan 22, 2014 at 5:29 AM, Alvaro Herrera
> <alvherre(at)2ndquadrant(dot)com> wrote:
>> I agree with Michael that having pg_basebackup be aware of the ".temp"
>> suffix is ugly; for instance if we were to fix it to ".tmp" in ALTER
>> SYSTEM but forgot to change pg_basebackup, the check would be
>> immediately broken. But on the other hand I'm not sure why it's such a
>> problem for pg_basebackup that it needs to be checking in the first
>> place -- how about we rip that out?
> Coupled with the addition of a pgsql_tmp prefix to the temp
> configuration file name would work, yes we could remove this check
> part.
>
>> Perhaps the temp file needs to be in pgsql_tmp? (Do we need to worry
>> about cross-filesystem links if we do? I mean, do we support mounting
>> pgsql_tmp separately?)
> Using pgsql_tmp looks a bit weird as well, as this prefix is used only
> for temporary files doing database-related operations, and ALTER
> SYSTEM is not one. Doing that this would need a mention in the docs at
> least:
> http://www.postgresql.org/docs/devel/static/storage-file-layout.html
> Thoughts?

I think moving the temp file to a different directory than the
permanent file is a non-starter. As Alvaro says, that could be on a
different file system, and then attempting to rename() the file into
place would fail.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-27 02:29:19
Message-ID: CAB7nPqTW3EGkF7M_mR=yARdcWr653d-PE6t4Spqo9o98QmLVuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Please find attached an updated patch (context diffs) improving the
comments related to ALTER SYSTEM. This patch does nothing for the
suffix tmp/temp used in a couple of places of the code, it only
corrects some typos and makes the comments more consistent with
current code.

The inconsistencies with the temporary file suffixes should be tackled
in a separate patch/thread.
Thanks,
--
Michael

Attachment Content-Type Size
20140127_alter_system_typos.patch text/plain 8.4 KB

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-27 02:53:01
Message-ID: CAB7nPqSTELou1FpB6dkaVMezfm6gMP8HnZUTnFQwx0GL0rxH4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 27, 2014 at 11:29 AM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> Hi,
>
> Please find attached an updated patch (context diffs) improving the
> comments related to ALTER SYSTEM. This patch does nothing for the
> suffix tmp/temp used in a couple of places of the code, it only
> corrects some typos and makes the comments more consistent with
> current code.
And I almost forgot the second patch simply changing the suffix from
temp to tmp for the temporary conf file... Now attached.
Regards,
--
Michael

Attachment Content-Type Size
20140127_alter_system_tmp_suffix.patch text/plain 1.2 KB

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-27 03:49:06
Message-ID: CAHGQGwH=ghqbvnQF=qYAfNgSde4mqya+ZUktQOjP=aaWYwp-Nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 27, 2014 at 11:53 AM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> On Mon, Jan 27, 2014 at 11:29 AM, Michael Paquier
> <michael(dot)paquier(at)gmail(dot)com> wrote:
>> Hi,
>>
>> Please find attached an updated patch (context diffs) improving the
>> comments related to ALTER SYSTEM. This patch does nothing for the
>> suffix tmp/temp used in a couple of places of the code, it only
>> corrects some typos and makes the comments more consistent with
>> current code.
> And I almost forgot the second patch simply changing the suffix from
> temp to tmp for the temporary conf file... Now attached.
> Regards,

Thanks for the patches! Committed.

Regards,

--
Fujii Masao


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER SYSTEM SET typos and fix for temporary file name management
Date: 2014-01-27 04:34:29
Message-ID: CAB7nPqQO=Qi42yVgKLyqt3QErzq5Bwj104EaUdNnr-hZsQL3Ug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 27, 2014 at 12:49 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Mon, Jan 27, 2014 at 11:53 AM, Michael Paquier
> <michael(dot)paquier(at)gmail(dot)com> wrote:
>> On Mon, Jan 27, 2014 at 11:29 AM, Michael Paquier
>> <michael(dot)paquier(at)gmail(dot)com> wrote:
>>> Hi,
>>>
>>> Please find attached an updated patch (context diffs) improving the
>>> comments related to ALTER SYSTEM. This patch does nothing for the
>>> suffix tmp/temp used in a couple of places of the code, it only
>>> corrects some typos and makes the comments more consistent with
>>> current code.
>> And I almost forgot the second patch simply changing the suffix from
>> temp to tmp for the temporary conf file... Now attached.
>> Regards,
>
> Thanks for the patches! Committed.
Thanks.
--
Michael