Re: [HACKERS] pg_stat_statements temporary file

2012-05-28 Thread Andres Freund
On Friday, May 25, 2012 05:19:28 PM Tom Lane wrote: > Andres Freund writes: > > On Friday, May 25, 2012 04:03:49 PM Peter Geoghegan wrote: > >> Where do you suggest the file be written to? > > > > One could argue stats_temp_directory would be the correct place. > > No, that would be exactly the

Re: [HACKERS] pg_stat_statements temporary file

2012-05-27 Thread Magnus Hagander
On Friday, May 25, 2012, Tom Lane wrote: > Andres Freund > writes: > > On Friday, May 25, 2012 04:03:49 PM Peter Geoghegan wrote: > >> Where do you suggest the file be written to? > > > One could argue stats_temp_directory would be the correct place. > > No, that would be exactly the *wrong* place

Re: [HACKERS] pg_stat_statements temporary file

2012-05-27 Thread Magnus Hagander
On Friday, May 25, 2012, Peter Geoghegan wrote: > On 25 May 2012 14:13, Magnus Hagander > > wrote: > > Here's a patch that does the two easy fixes: > > 1) writes the file to a temp file and rename()s it over the main file > > as it writes down. This removes the (small) risk of corruption because >

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Josh Berkus
> Why would they want that? PSS only writes the tempfile on shutdown and > reads it on startup. Unlike pgstats which reads and writes it all the > time. Ah, ok! Didn't know that. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-hackers mailing list (pgsql-hacker

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Magnus Hagander
On Fri, May 25, 2012 at 6:49 PM, Josh Berkus wrote: > On 5/25/12 8:19 AM, Tom Lane wrote: >> Andres Freund writes: >>> On Friday, May 25, 2012 04:03:49 PM Peter Geoghegan wrote: Where do you suggest the file be written to? >> >>> One could argue stats_temp_directory would be the correct plac

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Josh Berkus
On 5/25/12 8:19 AM, Tom Lane wrote: > Andres Freund writes: >> On Friday, May 25, 2012 04:03:49 PM Peter Geoghegan wrote: >>> Where do you suggest the file be written to? > >> One could argue stats_temp_directory would be the correct place. > > No, that would be exactly the *wrong* place, becaus

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Tom Lane
Andres Freund writes: > On Friday, May 25, 2012 04:03:49 PM Peter Geoghegan wrote: >> Where do you suggest the file be written to? > One could argue stats_temp_directory would be the correct place. No, that would be exactly the *wrong* place, because that directory can be on a RAM disk. We need

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Tom Lane
Magnus Hagander writes: > On Fri, May 25, 2012 at 4:09 PM, Tom Lane wrote: >> Given that pgstats keeps its permanent file in global/, I think the >> argument that pg_stat_statements should not do likewise is pretty thin. > Fair enough. As long as the file is unlinked after reading (per my > patc

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Magnus Hagander
On Fri, May 25, 2012 at 4:09 PM, Tom Lane wrote: > Peter Geoghegan writes: >> On 25 May 2012 14:13, Magnus Hagander wrote: >>> I still think we should consider the placement of this file to not be >>> in the global/ directory, but this is a quick (back-patchable) fix... > >> Where do you suggest

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Tom Lane
Peter Geoghegan writes: > On 25 May 2012 14:13, Magnus Hagander wrote: >> I still think we should consider the placement of this file to not be >> in the global/ directory, but this is a quick (back-patchable) fix... > Where do you suggest the file be written to? Given that pgstats keeps its pe

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Andres Freund
On Friday, May 25, 2012 04:03:49 PM Peter Geoghegan wrote: > > I still think we should consider the placement of this file to not be > > in the global/ directory, but this is a quick (back-patchable) fix... > > Where do you suggest the file be written to? One could argue stats_temp_directory would

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Peter Geoghegan
On 25 May 2012 14:13, Magnus Hagander wrote: > Here's a patch that does the two easy fixes: > 1) writes the file to a temp file and rename()s it over the main file > as it writes down. This removes the (small) risk of corruption because > of a crash during write > > 2) unlinks the file after readi

Re: [HACKERS] pg_stat_statements temporary file

2012-05-25 Thread Magnus Hagander
On Thu, May 24, 2012 at 2:19 PM, Magnus Hagander wrote: > On Thu, May 24, 2012 at 2:16 PM, Peter Geoghegan > wrote: >> On 24 May 2012 12:42, Magnus Hagander wrote: >>> What actually happens if it tries to repalloc() something huge? palloc >>> will throw an elog(ERROR), and since this happens du

Re: [HACKERS] pg_stat_statements temporary file

2012-05-24 Thread Magnus Hagander
On Thu, May 24, 2012 at 2:16 PM, Peter Geoghegan wrote: > On 24 May 2012 12:42, Magnus Hagander wrote: >> What actually happens if it tries to repalloc() something huge? palloc >> will throw an elog(ERROR), and since this happens during postmaster >> startup, are you sure it won't prevent the ser

Re: [HACKERS] pg_stat_statements temporary file

2012-05-24 Thread Peter Geoghegan
On 24 May 2012 12:42, Magnus Hagander wrote: > What actually happens if it tries to repalloc() something huge? palloc > will throw an elog(ERROR), and since this happens during postmaster > startup, are you sure it won't prevent the server from starting? Oh, yes, missed that. /*

Re: [HACKERS] pg_stat_statements temporary file

2012-05-24 Thread Magnus Hagander
On Thu, May 24, 2012 at 1:36 PM, Peter Geoghegan wrote: > On 24 May 2012 11:43, Magnus Hagander wrote: >> In general, should a contrib module really store data in the global/ >> directory? Seems pretty ugly to me... > > I think the case could be made for moving pg_stat_statements into > core, as

Re: [HACKERS] pg_stat_statements temporary file

2012-05-24 Thread Peter Geoghegan
On 24 May 2012 11:43, Magnus Hagander wrote: > In general, should a contrib module really store data in the global/ > directory? Seems pretty ugly to me... I think the case could be made for moving pg_stat_statements into core, as an optionally enabled view, like pg_stat_user_functions, since pg_

[HACKERS] pg_stat_statements temporary file

2012-05-24 Thread Magnus Hagander
If pg_stat_statements is set to store it's data across restarts, it stores it in global/pg_stat_statements.stat. This causes some interesting things to happen in combination with a base backup - namely, if you take a base backup *after* you have restarted th emaster, the slave will get a snapshot o