Re: [PATCHES] Patch to log usage of temporary files - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [PATCHES] Patch to log usage of temporary files
Date
Msg-id 200701092216.l09MGnP20739@momjian.us
Whole thread Raw
In response to Re: [PATCHES] Patch to log usage of temporary files  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCHES] Patch to log usage of temporary files
Re: [PATCHES] Patch to log usage of temporary files
List pgsql-hackers
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > +         A value of zero logs all temporary files, and positive
> > +         values log only files whose size is equal or greater than
> > +         the specified number of bytes.
>
> Surely the measurement unit should be kbytes or disk blocks.  And why
> aren't you using that GUC UNITS infrastructure Peter put in?

Agreed.  I have applied the following patch to make it kilobytes, and
documented it.  I didn't put '-1kB' in the postgresql.conf file because
the -1 value is special.  (ideas?)

> >           /* reset flag so that die() interrupt won't cause problems */
> >           vfdP->fdstate &= ~FD_TEMPORARY;
> > +         PG_TRACE1(temp__file__cleanup, vfdP->fileName);
> > +         if (log_temp_files >= 0)
> > +         {
> > +             if (stat(vfdP->fileName, &filestats) == 0)
>
> The TRACE is in the wrong place no?  I thought it was going to be after
> the stat() operation so it could pass the file size.
>
> Also, I dunno much about DTrace, but I had the idea that you can't
> simply throw a PG_TRACE macro into the source and think you are done
> --- isn't there a file of probe declarations to add to?  Not to mention
> the documentation of what probes exist.

I didn't like the macro in that area anyway.  It seems too adhock to
just throw it in when we have so few places monitored now.  Removed.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/config.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/config.sgml,v
retrieving revision 1.100
diff -c -c -r1.100 config.sgml
*** doc/src/sgml/config.sgml    9 Jan 2007 21:31:14 -0000    1.100
--- doc/src/sgml/config.sgml    9 Jan 2007 22:15:40 -0000
***************
*** 2930,2936 ****
          Controls whether temporary files are logged when deleted.
          A value of zero logs all temporary files, and positive
          values log only files whose size is equal or greater than
!         the specified number of bytes.  Temporary files can be
          created for sorts, hashes, and temporary results.  The
          default is <literal>-1</> (off).
         </para>
--- 2930,2936 ----
          Controls whether temporary files are logged when deleted.
          A value of zero logs all temporary files, and positive
          values log only files whose size is equal or greater than
!         the specified number of kilobytes.  Temporary files can be
          created for sorts, hashes, and temporary results.  The
          default is <literal>-1</> (off).
         </para>
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.366
diff -c -c -r1.366 guc.c
*** src/backend/utils/misc/guc.c    9 Jan 2007 21:31:14 -0000    1.366
--- src/backend/utils/misc/guc.c    9 Jan 2007 22:15:43 -0000
***************
*** 1664,1672 ****

      {
          {"log_temp_files", PGC_USERSET, LOGGING_WHAT,
!             gettext_noop("Log the use of temporary files larger than this size."),
              gettext_noop("Zero logs all files. The default is -1 (turning this feature off)."),
!             NULL
          },
          &log_temp_files,
          -1, -1, INT_MAX, NULL, NULL
--- 1664,1672 ----

      {
          {"log_temp_files", PGC_USERSET, LOGGING_WHAT,
!             gettext_noop("Log the use of temporary files larger than this number of kilobytes."),
              gettext_noop("Zero logs all files. The default is -1 (turning this feature off)."),
!             GUC_UNIT_KB
          },
          &log_temp_files,
          -1, -1, INT_MAX, NULL, NULL
Index: src/backend/utils/misc/postgresql.conf.sample
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.200
diff -c -c -r1.200 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample    9 Jan 2007 21:31:16 -0000    1.200
--- src/backend/utils/misc/postgresql.conf.sample    9 Jan 2007 22:15:43 -0000
***************
*** 334,340 ****
  #log_hostname = off

  #log_temp_files = -1            # Log temporary files equal or larger
!                     # than the specified number of bytes.
                      # -1 disables;  0 logs all temp files

  #---------------------------------------------------------------------------
--- 334,340 ----
  #log_hostname = off

  #log_temp_files = -1            # Log temporary files equal or larger
!                     # than the specified number of kilobytes.
                      # -1 disables;  0 logs all temp files

  #---------------------------------------------------------------------------

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCHES] Patch to log usage of temporary files
Next
From: Bruce Momjian
Date:
Subject: Re: [PATCHES] SGML index build fix