Thread

  1. Re: [Proposal] Adding callback support for custom statistics kinds

    Sami Imseih <samimseih@gmail.com> — 2025-12-09T03:57:15Z

    > +                                       if (kind_info->from_serialized_extra_stats)
    > +                                       {
    > +                                               if (!kind_info->from_serialized_extra_stats(&key, header, fpin))
    > +                                               {
    > +                                                       elog(WARNING, "could not read extra stats for entry %u/%u/%" PRIu64,
    > +                                                                key.kind, key.dboid, key.objid);
    > +                                                       goto error;
    > +                                               }
    > +                                       }
    > ```
    >
    > When deserialize failed, it goes to error. In the error clause, it calls pgstat_reset_after_failure(), so do we want to give extensions a chance to do some reset operations? If yes, then we can add a reset_after_failure() callback.
    
    The way v5 is dealing with a deserialize failure is that when
    it goes to error, the pgstat_reset_after_failure() will reset the
    stats for all kinds, since pgstat_drop_all_entries() is called
    during that call. So there is nothing for an extension to have
    to do on its own. The extension will then clean-up resources
    at the end when  all the kinds are iterated over and
    kind_info->end_extra_stats(STATS_READ) is called for each
    kind.
    
    Let me know if I'm still missing something?
    
    --
    Sami Imseih
    Amazon Web Services (AWS)