| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> |
| Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] pgstat: Add helper to drop entries from a stats kind's hash |
| Date: | 2026-11-02 00:35:50 |
| Message-ID: | aufa5srSxC4pu5OF@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Oct 30, 2026 at 09:41:12AM -0500, Sami Imseih wrote:
> Hmm, yeah. v5 adds PGSTAT_KIND_ALL and uses that for the all-kinds
> case.
PGSTAT_KIND_ALL holds the same meaning as PGSTAT_KIND_INVALID on an
interface-basis. I'd just rely on PGSTAT_KIND_INVALID, drop
PGSTAT_KIND_ALL; that seems simpler overall.
> Adding an all-kinds scan with a non-NULL callback did cross my mind,
> but I did not want to overdo the tests. I also did not realize that this
> used to be covered by the injection_points test, so thanks for the
> research.
>
> v5 now has these pgstat_drop_matching_entries() cases:
>
> 1. Specific kind + non-NULL callback
> 2. All kinds + non-NULL callback (similar to the injection points test
> functionally)
> 3. Specific kind + NULL callback
The NULL callback case is already covered by the in-core code, for
example where we drop all the entries during a reset. I don't see a
specific need for more coverage with this pattern.
-static bool
-match_inj_entries(PgStatShared_HashEntry *entry, Datum match_data)
-{
- return entry->key.kind == PGSTAT_KIND_INJECTION;
-}
[...]
-injection_points_stats_drop(PG_FUNCTION_ARGS)
-{
- pgstat_drop_matching_entries(match_inj_entries, 0);
-
- PG_RETURN_VOID();
Hmmm... Indeed... We used to have a pgstat_drop_matching_entries()
call that we have dropped when moving these tests from
injection_points to test_custom_stats. That was not intentional.
I think that your test_custom_stats_var_drop_all() makes sense, with
a callback that matches with the variable-sized kind ID. This should
be backpatched down to v19, perhaps, but I'm mild with playing with
this stable branch as we are close to release. And this is just for a
small gap in the tests.
Anyway, what do you think about the attached to address this hole in
the tests? I'll continue my review of the main patch once this issue
is fixed.
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-test_custom_stats-Add-test-for-dropped-stats.patch | text/plain | 3.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jim Jones | 2026-11-02 00:44:13 | Fix use-after-free when XMLSERIALIZE(... INDENT) output exceeds 1GB |
| Previous Message | Tom Lane | 2026-11-01 22:29:26 | Re: [PG19] Bogus errors for polymorphic plpython functions |