On Tue, Feb 22, 2022 at 8:02 PM Masahiko Sawada <sawada.m...@gmail.com> wrote: > > On Tue, Feb 22, 2022 at 6:53 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > > > > 3. Can we send error stats pgstat_report_stat() as that will be called > > via proc_exit() path. We can set the phase (apply/sync) in > > apply_error_callback_arg and then use that to send the appropriate > > message. I think this will obviate the need for try..catch. > > If we use pgstat_report_stat() to send subscription stats messages, > all processes end up going through that path. It might not bring > overhead in practice but I'd like to avoid it. >
I am not sure about overhead but I see another problem if we use that approach. In the exit path, logicalrep_worker_onexit() will get called before pgstat_report_stat() and that will clear the MyLogicalRepWorker->subid, so we won't know the id for which to send stats. So, the way patch is doing seems reasonable to me unless someone has better ideas. -- With Regards, Amit Kapila.