From: | Jim Nasby <jnasby(at)upgrade(dot)com> |
---|---|
To: | Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru> |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Andrei Zubkov <zubkov(at)moonset(dot)ru>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, a(dot)lepikhov(at)postgrespro(dot)ru, Sami Imseih <samimseih(at)gmail(dot)com> |
Subject: | Re: Vacuum statistics |
Date: | 2025-03-24 23:02:31 |
Message-ID: | CAMFBP2o=K-+EBiOb70F8pHmW9f0O3iDLtyV5MjgeCgBvWUQsdg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Mar 21, 2025 at 2:42 PM Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>
wrote:
> On 13.03.2025 09:42, Bertrand Drouvot wrote:
>
> Hi,
>
> On Wed, Mar 12, 2025 at 05:15:53PM -0500, Jim Nasby wrote:
>
> The usecase I can see here is that we don't want autovac creating so much
> WAL traffic that it starts forcing other backends to have to write WAL out.
> But tracking how many times autovac writes WAL buffers won't help with that
>
> Right, because the one that increments the wal_buffers_full metric could "just"
> be a victim (i.e the one that happens to trigger the WAL buffers disk flush,
> even though other backends contributed most of the buffer usage).
>
>
> (though we also don't want any WAL buffers written by autovac to be counted
> in the system-wide wal_buffers_full:
>
> why? Or do you mean that it would be good to have 2 kinds of metrics: one
> generated by "maintenance" activity and one by "regular" backends?
>
> See below...
> What would be helpful would be a way to determine if autovac was causing
> enough traffic to force other backends to write WAL. Offhand I'm not sure
> how practical that actually is though.
>
> a051e71e28a could help to see how much WAL has by written by the autovac workers.
>
> I still don't think that helps (see below)
> BTW, there's also an argument to be made that autovac should throttle
> itself if we're close to running out of available WAL buffers...
>
> hmm, yeah I think that's an interesting idea OTOH that would mean to "delegate"
> the WAL buffers flush to another backend.
>
> Maybe it does, maybe it doesn't... but now I think you're getting why I'm
complaining about the proposed WAL flush metrics: who *flushes* WAL tells
you absolutely nothing about who generated the WAL. Not only that, but
flushing WAL isn't necessarily even bad: a user backend can't COMMIT
without flushing some amount of WAL (ignoring async-commit of course). That
really casts the whole idea of having stats on who's flushing how much WAL
in a new light: you can NOT use any such metric without a bunch of other
context; including who else was flushing how much WAL, whether WAL had to
absolutely be flushed anyway (ie, at bare minimum a COMMIT must flush
enough WAL to cover the commit record), and even where all the WAL is
coming from in the first place.
Though now that I think about it... if we're reporting how much WAL is
being generated by vacuum, then *maybe* it's helpful to also report how
much WAL is being flushed by vacuum. My emphasis on *maybe* is because it's
fine if autovac is writing more than it flushes, so long as the remainder
is being flushed by the checkpointer and not user backends... but you could
also determine that just by looking at how much WAL backends are flushing.
Basically, I'm leaning towards it would be best to rethink the whole
purpose of reporting WAL flush metrics before we further muddy the waters
by adding vacuum stats about it. At minimum we should have a metric that
shows how much WAL backends flushed because they *had* to due to
synchronous commit settings (which does affect more than just COMMIT).
> I will add it and fix the tests but later and I'll explain why.
>
> I'm working on this issue [0] and try have already created new statistics
> in Statistics Collector to store database and relation vacuum statistics:
> PGSTAT_KIND_VACUUM_DB and PGSTAT_KIND_VACUUM_RELATION.
>
> Vacuum statistics are saved there instead of relation's and database's
> statistic structure, but for some reason it is not possible to find them in
> the hash table when building a snapshot and display them accordingly.
> I have not yet figured out where the error is.
>
> Without solving this problem, committing vacuum statistics is not yet
> possible. An alternative way for us was to refuse some statistics for now
> for relations,
> but we could not agree on which statistics should not be displayed yet and
> for now we are only adding them :).
>
> I understand why this is important to display more vacuum information
> about vacuum statistics - it will allow us to better understand the
> problems of incorrect vacuum settings or, for example, notice a bug in its
> operation.
>
> In order to reduce the memory consumption for storing them for those who
> are not going to use them, I just realized that we need to create a
> separate space for storing the statistics
> I mentioned above (PGSTAT_KIND_VACUUM_DB and PGSTAT_KIND_VACUUM_RELATION),
> there is no other way to do this and I am still trying to complete this
> functionality.
>
> I doubt that I will have time for this by code freeze date and even if I
> do, I will hardly have time for a normal review. There's really a lot more
> to learn related to the stat collector, so
> I'm postponing it to the next commitfest.
>
> Sorry. I'll fix the tests as soon as I finish this part, since they'll
> most likely either break the same way or in some new way.
>
> Tomorrow or the day after tomorrow I will send a diff patch with what I
> have already managed to demonstrate the problem, since I need to bring the
> code to a normal form.
> Maybe someone who worked with the stat collector will suddenly tell me
> where and what I have implemented incorrectly.
>
> --
> Regards,
> Alena Rybakina
> Postgres Professional
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Sami Imseih | 2025-03-24 23:47:59 | Re: Proposal - Allow extensions to set a Plan Identifier |
Previous Message | Andres Freund | 2025-03-24 22:55:22 | Re: AIO v2.5 |