Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system
Date
Msg-id 20130214192358.GE4747@alvh.no-ip.org
Whole thread Raw
In response to Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system  (Tomas Vondra <tv@fuzzy.cz>)
List pgsql-hackers
Here's a ninth version of this patch.  (version 8 went unpublished).  I
have simplified a lot of things and improved some comments; I think I
understand much of it now.  I think this patch is fairly close to
committable, but one issue remains, which is this bit in
pgstat_write_statsfiles():

    /* In any case, we can just throw away all the db requests, but we need to
     * write dummy files for databases without a stat entry (it would cause
     * issues in pgstat_read_db_statsfile_timestamp and pgstat wait timeouts).
     * This may happen e.g. for shared DB (oid = 0) right after initdb.
     */
    if (!slist_is_empty(&last_statrequests))
    {
        slist_mutable_iter    iter;

        slist_foreach_modify(iter, &last_statrequests)
        {
            DBWriteRequest *req = slist_container(DBWriteRequest, next,
                                                  iter.cur);

            /*
             * Create dummy files for requested databases without a proper
             * dbentry. It's much easier this way than dealing with multiple
             * timestamps, possibly existing but not yet written DBs etc.
             * */
            if (!pgstat_get_db_entry(req->databaseid, false))
                pgstat_write_db_dummyfile(req->databaseid);

            pfree(req);
        }

        slist_init(&last_statrequests);
    }

The problem here is that creating these dummy entries will cause a
difference in autovacuum behavior.  Autovacuum will skip processing
databases with no pgstat entry, and the intended reason is that if
there's no pgstat entry it's because the database doesn't have enough
activity.  Now perhaps we want to change that, but it should be an
explicit decision taken after discussion and thought, not side effect
from an unrelated patch.

Hm, and I now also realize another bug in this patch: the global stats
only include database entries for requested databases; but perhaps the
existing files can serve later requestors just fine for databases that
already had files; so the global stats file should continue to carry
entries for them, with the old timestamps.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system
Next
From: Manlio Perillo
Date:
Subject: Re: [RFC] ideas for a new Python DBAPI driver (was Re: libpq test suite)