Thread: postmaster grows

postmaster grows

From
Max Vaschenko
Date:
Hi.
I have a RedHat Linux 6.2 (kernel 2.2.18pre1 SMP) on Intel platform.
Postgres-7.0.3-2 (RPM).
It grows. Initially about 5mb it grows to 60-70 mb after 2-3 weeks.
I use plpgsql.
If it does matter, server have a chrooted area. Postgres is running in root
but accessed both from root and from chroot (via hardlinked socket /tmp/.s.PGSQL.5432)
Some times ago i upgraded it from 7.0.2 version, that grew too.


--
ó Õ×ÁÖÅÎÉÅÍ, ÷ÁÝÅÎËÏ íÁËÓÉÍ,
îÉÖÅÇÏÒÏÄÓËÉÅ ÉÎÆÏÒÍÁÃÉÏÎÎÙÅ ÓÅÔÉ
(8312) 30-19-05, 34-00-02, 30-09-73

With best regards, Max Vaschenko,
Nizhny Novgorod Information Networks.

Re: postmaster grows

From
Tom Lane
Date:
Max Vaschenko <max@nino.ru> writes:
> I have a RedHat Linux 6.2 (kernel 2.2.18pre1 SMP) on Intel platform.
> Postgres-7.0.3-2 (RPM).
> It grows. Initially about 5mb it grows to 60-70 mb after 2-3 weeks.

Is this the *postmaster* that's growing, or an individual backend that
you've kept running for a long time?

We've fixed a fair number of memory leaks in the backend since 7.0.*,
but there aren't any known leaks in the postmaster ...

            regards, tom lane

Re: postmaster grows

From
Max Vaschenko
Date:
Tom Lane wrote:
>
> Max Vaschenko <max@nino.ru> writes:
> > I have a RedHat Linux 6.2 (kernel 2.2.18pre1 SMP) on Intel platform.
> > Postgres-7.0.3-2 (RPM).
> > It grows. Initially about 5mb it grows to 60-70 mb after 2-3 weeks.
>
> Is this the *postmaster* that's growing, or an individual backend that
> you've kept running for a long time?

One backend is running long time (2-3 weeks), but i don't pay attension on it.
Growing affected on both postmaster and individual backends (running usually less than 1 minute).
After some (2-3 weeks) time both postmaster and all (every) backends take
about 60mb memory.

>
> We've fixed a fair number of memory leaks in the backend since 7.0.*,
> but there aren't any known leaks in the postmaster ...

May be backend that running long time, causes other postgres processes to grow?

>
>                         regards, tom lane

--
ó Õ×ÁÖÅÎÉÅÍ, ÷ÁÝÅÎËÏ íÁËÓÉÍ,
îÉÖÅÇÏÒÏÄÓËÉÅ ÉÎÆÏÒÍÁÃÉÏÎÎÙÅ ÓÅÔÉ
(8312) 30-19-05, 34-00-02, 30-09-73

With best regards, Max Vaschenko,
Nizhny Novgorod Information Networks.

Re: postmaster grows

From
Tom Lane
Date:
Max Vaschenko <max@nino.ru> writes:
> After some (2-3 weeks) time both postmaster and all (every) backends take
> about 60mb memory.

Okay, then it is a postmaster leak.  The backends are started by fork
from the postmaster, so they'd inherit whatever data memory size the
postmaster currently has.

> May be backend that running long time, causes other postgres processes
> to grow?

Not possible for a backend to affect the postmaster like that, AFAICS.
I think it's just a garden-variety memory leak in some postmaster
operation.

Since this isn't being reported by other folks, either there's a
system-specific problem or you are using a postmaster feature that's not
widely used.  RedHat 6.2 is pretty common so we can probably eliminate
system-specific issues.  Which authentication method(s) do you use?
(If you could send your whole pg_hba.conf file, that might be useful to
look at.)

            regards, tom lane

Re: postmaster grows

From
Max Vaschenko
Date:
Tom Lane wrote:
>
> Max Vaschenko <max@nino.ru> writes:
> > After some (2-3 weeks) time both postmaster and all (every) backends take
> > about 60mb memory.
>
> Okay, then it is a postmaster leak.  The backends are started by fork
> from the postmaster, so they'd inherit whatever data memory size the
> postmaster currently has.
>
> > May be backend that running long time, causes other postgres processes
> > to grow?
>
> Not possible for a backend to affect the postmaster like that, AFAICS.
> I think it's just a garden-variety memory leak in some postmaster
> operation.
>
> Since this isn't being reported by other folks, either there's a
> system-specific problem or you are using a postmaster feature that's not
> widely used.  RedHat 6.2 is pretty common so we can probably eliminate
> system-specific issues.  Which authentication method(s) do you use?
> (If you could send your whole pg_hba.conf file, that might be useful to
> look at.)

----- pg_hba.conf --
local all                                  password
host  all    127.0.0.1    255.255.255.255  password
host  all    xxx.xx.x.xx  255.255.255.255  password
host  all    xxx.xx.x.xx  255.255.255.255  password
host  all    xxx.xx.x.xx  255.255.255.255  password
host  all    xxx.xx.x.xx  255.255.255.255  password
--------------------

Four databases with some simple plpgsql triggers.
Access to postgres from C and PHP3.


>
>                         regards, tom lane

--
ó Õ×ÁÖÅÎÉÅÍ, ÷ÁÝÅÎËÏ íÁËÓÉÍ,
îÉÖÅÇÏÒÏÄÓËÉÅ ÉÎÆÏÒÍÁÃÉÏÎÎÙÅ ÓÅÔÉ
(8312) 30-19-05, 34-00-02, 30-09-73

With best regards, Max Vaschenko,
Nizhny Novgorod Information Networks.

Re: postmaster grows

From
Tom Lane
Date:
Max Vaschenko <max@nino.ru> writes:
> [ postmaster leaks memory when using password authentication ]

You are right!  The postmaster leaks memory to the tune of a few dozen
bytes per password authentication attempt.  I'm surprised no one noticed
this before.  People must not be using password auth under heavy load...

Attached is a patch to fix it in 7.0.*.

            regards, tom lane


*** src/backend/libpq/crypt.c.orig    Sat Jul 17 16:17:01 1999
--- src/backend/libpq/crypt.c    Wed Feb  7 18:40:01 2001
***************
*** 59,64 ****
--- 59,65 ----
      bufsize = strlen(pwdfilename) + strlen(CRYPT_PWD_RELOAD_SUFX) + 1;
      rpfnam = (char *) palloc(bufsize);
      snprintf(rpfnam, bufsize, "%s%s", pwdfilename, CRYPT_PWD_RELOAD_SUFX);
+     pfree(pwdfilename);

      return rpfnam;
  }
***************
*** 79,84 ****
--- 80,87 ----
      pwdfile = AllocateFile(filename, "rb");
  #endif

+     pfree(filename);
+
      return pwdfile;
  }

***************
*** 131,136 ****
--- 134,140 ----

      filename = crypt_getpwdreloadfilename();
      result = unlink(filename);
+     pfree(filename);

      /*
       * We want to delete the flag file before reading the contents of the