Re: [PERFORM] Postgres log(pg_logs) have lots of message

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Nik Tek <niktek2005(at)gmail(dot)com>
Cc: Bambi Bellows <bbellows(at)dotomi(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: [PERFORM] Postgres log(pg_logs) have lots of message
Date: 2013-04-12 06:14:10
Message-ID: CAMkU=1zxKqxuLP-aJSnCdmhJS+fns6YkEVsXxmvJPptrwWAMSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-performance

On Wednesday, April 10, 2013, Nik Tek wrote:

> Hi Bambi,
>
> Thank you the prompt reply.
>
> This table is very volatile, lot of inserts/updates happen on this
> tables(atleast 20~30 inserts/min).
>

That number of inserts per minute is not all that many. I suspect that you
have sessions which are holding open transactions (and thus locks) for much
longer than necessary, and it is this idling on the locks, not the active
insertions, that is causing the current problem.

If this is true, you should try to find the idle-in-transaction connections
and fix them, because even if they didn't cause this particular problem,
they will cause other ones.

> When auto vacuum tries to run on this table, I get this warning.
>

>> LOG: automatic vacuum of table "DB1.nic.pvxt": could not (re)acquire
exclusive lock for truncate scan

You have at least 8 MB of empty space at the end of the table, but to
remove it it needs to acquire a lock that it cannot get and so it gives up.
Unfortunately it now gives up on the following autoanalyze as well. In
9.2.2 and before, it would also give up on reclaiming the free space, but
would likely still do the autoanalyze, which is probably why you didn't see
it before.

> Is there a way, I force it to happen, because the table/indexes statistics
> are becoming stale very quickly.
>

This is something introduced in 9.2.3, and will probably be fixed whenever
9.2.5 comes out.

In the mean time, a manual ANALYZE (But not a VACUUM ANALYZE, because would
fail the same was autvac does) would fix the stats, but it would have to be
repeated often as they would just get stale again.

You could try a VACUUM FULL or CLUSTER if you can tolerate the lock it
would hold on the table while it operates. The reason that might solve the
problem for you is that it would clear out the empty space, and therefore
future autovac won't see that empty space and try to truncate it.
Depending on how your table is used, either more empty space could
accumulate at the end of the table causing the problem to recur, or maybe
it would fix the problem for good.

Cheers,

Jeff

>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message X.H.----WANG 2013-04-12 07:08:59 Re: with PostgreSQL 9.1.9,the stats collector process is not work!
Previous Message Kevin Grittner 2013-04-12 01:52:42 Re: Invalid SQL not rejected?

Browse pgsql-performance by date

  From Date Subject
Next Message Richard Huxton 2013-04-12 10:02:02 Re: PsqL8.3
Previous Message bing1221 2013-04-11 23:30:54 High CPU usage buy low I/O wait