pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tv@fuzzy.cz>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #12071: Stat collector went crasy (50MB/s constant writes)
Date: Wed, 26 Nov 2014 23:26:34 +0100
Message-ID: <5476539A.6090506@fuzzy.cz> (raw)
In-Reply-To: <CAK-MWwRzyzX=BfXkMzPGGWCpxgHmc_zBXBYkp74PkYqQLrjtbQ@mail.gmail.com>
References: <20141126130810.15507.39189@wrigleys.postgresql.org>
	<CAK-MWwSDmXTWCc3F2Wj3Zw6WZ_3JSKHaXFqZ2TDuq1jfKZOu=A@mail.gmail.com>
	<CAK-MWwQJF+EM5f_47r5wLpr6_2FBYNFeKKAD-DPP3JtzuAM15Q@mail.gmail.com>
	<CAK-MWwTmJV4VprhAfCyTKRLndYbwbToF-Z0JYv6_o=qq3VYxyQ@mail.gmail.com>
	<54763BD8.8020906@fuzzy.cz>
	<CAK-MWwTFTRVuBjLz_rJVNEompGj2btot88G5uwXW+d2DierSNQ@mail.gmail.com>
	<CAK-MWwSK5AUneiF5zyDvc_9pO4ZNTT_G45ZQG1AD+n55s2zzTg@mail.gmail.com>
	<54764BF6.20605@fuzzy.cz>
	<CAK-MWwRzyzX=BfXkMzPGGWCpxgHmc_zBXBYkp74PkYqQLrjtbQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 26.11.2014 23:06, Maxim Boguk wrote:
> 
> 
>     I'm not sure I understand what you mean.
> 
>     The timestamp *IS* updated on every write - see this:
> 
>     https://github.com/postgres/postgres/blob/REL9_2_STABLE/src/backend/postmaster/pgstat.c#L3469
> 
> 
>  I mean that usually 99.9% writes goes through mmap, which update the
> pgstat.tmp file timestamp (but not update last_statwrite value).

I don't follow. Can you explain what you mean by the mmap? I don't see
any mmap stuff in pgstat.c, nor I remember dealing with mmap in my
patches in this area ...

You mentioned the snippet:

    if (last_statwrite < last_statrequest)
        pgstat_write_statsfile(false);

and essentially what pgstat_write_statsfile() does is this:


    1) open pgstat.tmp file
    2) update globalStats.stats_timestamp to GetCurrentTimestamp();
    3) write globalStats to the new file
    4) ...

so it *does* update the timestamp on each write.

> But that enough to make backend_read_statsfile happy around
> https://github.com/postgres/postgres/blob/REL9_2_STABLE/src/backend/postmaster/pgstat.c#L3972
> without kicking  poor statistic collector (and forcing full file rewrite) at
> https://github.com/postgres/postgres/blob/REL9_2_STABLE/src/backend/postmaster/pgstat.c#L3978

Well, the thing is that with 10 databases and 1s naptime, the launcher
starts a new autovacuum process every 100 ms. The first thing every
worker does is pgstat_read_statsfile() and this checks whether the stats
are older than 10 ms (which it is, because the last worker started
~100ms ago), and sends a new inquiry.

Regular backends use 640ms threshold, which is less than 100ms.

> PS: 1second autovacuum_naptime could be useful if you have small but
> very very actively updated tables, over 1 minute they could growth
> 100-500x size without autovacuum.
> 1minute naptime will have the same issue with 500 small idle databases :).

True. That's why I have reworked this in 9.3.

Anyway, this is not a bug - it works as designed/expected. It may be
imperfect, but that's how it is. The only thing you can do in 9.2 is
moving the pgstat.tmp to a tmpfs filesystem

Tomas



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (24+ messages)  latest in thread

Message-ID: <5476539A.6090506@fuzzy.cz>
Permalink:  ../5476539A.6090506@fuzzy.cz/
Also on:    postgresql.org/message-id/5476539A.6090506@fuzzy.cz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tv@fuzzy.cz
  Subject: Re: BUG #12071: Stat collector went crasy (50MB/s constant writes)
  In-Reply-To: <5476539A.6090506@fuzzy.cz>
  References: <20141126130810.15507.39189@wrigleys.postgresql.org> <CAK-MWwSDmXTWCc3F2Wj3Zw6WZ_3JSKHaXFqZ2TDuq1jfKZOu=A@mail.gmail.com> <CAK-MWwQJF+EM5f_47r5wLpr6_2FBYNFeKKAD-DPP3JtzuAM15Q@mail.gmail.com> <CAK-MWwTmJV4VprhAfCyTKRLndYbwbToF-Z0JYv6_o=qq3VYxyQ@mail.gmail.com> <54763BD8.8020906@fuzzy.cz> <CAK-MWwTFTRVuBjLz_rJVNEompGj2btot88G5uwXW+d2DierSNQ@mail.gmail.com> <CAK-MWwSK5AUneiF5zyDvc_9pO4ZNTT_G45ZQG1AD+n55s2zzTg@mail.gmail.com> <54764BF6.20605@fuzzy.cz> <CAK-MWwRzyzX=BfXkMzPGGWCpxgHmc_zBXBYkp74PkYqQLrjtbQ@mail.gmail.com> <5476539A.6090506@fuzzy.cz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox