Re: enhance pg_log_backend_memory_contexts() to log memory contexts of auxiliary processes

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: enhance pg_log_backend_memory_contexts() to log memory contexts of auxiliary processes
Date: 2022-01-07 16:50:02
Message-ID: CALj2ACUJqNsoihLVwXv9zi2MbiO2RwEajYm7rAtFZ_-FE_pBPw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 7, 2022 at 9:19 PM Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:
>
> On 2021/11/29 11:44, vignesh C wrote:
> > Thanks for the updated patch. The patch applies neatly, make
> > check-world passes and the documentation looks good. I did not find
> > any issues with the v6 patch, I'm marking the patch as Ready for
> > Committer.
>
> I started reading the patch.

Thanks.

> +CREATE FUNCTION memcxt_get_proc_pid(text)
> + RETURNS int
> + LANGUAGE SQL
> + AS 'SELECT pid FROM pg_stat_activity WHERE backend_type = $1';
> +
> +SELECT pg_log_backend_memory_contexts(memcxt_get_proc_pid('checkpointer'));
> +
> +DROP FUNCTION memcxt_get_proc_pid(text);
>
> Why is memcxt_get_proc_pid() still necessary? ISTM that we can just replace the above with the following query, instead.
>
> SELECT pg_log_backend_memory_contexts(pid) FROM pg_stat_activity WHERE backend_type = 'checkpointer'

Changed.

> I'm tempted to replace these descriptions as follows. Because the following looks simpler and easier to read and understand, to me.
> ----------------------
> Requests to log the memory contexts of the backend with the specified process ID. This function can send the request to also auxiliary processes except logger and stats collector.
> ----------------------

Changed.

> As Horiguchi-san told upthread, IMO it's simpler not to use is_aux_proc flag. For example, you can replace this code with
>
> ------------------------
> proc = BackendPidGetProc(pid);
>
> if (proc != NULL)
> backendId = proc->backendId;
> else
> proc = AuxiliaryPidGetProc(pid);
> ------------------------

Changed.

PSA v7 patch.

Regards,
Bharath Rupireddy.

Attachment Content-Type Size
v7-0001-enhance-pg_log_backend_memory_contexts-to-log-mem.patch application/octet-stream 9.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2022-01-07 16:52:00 Re: Add 64-bit XIDs into PostgreSQL 15
Previous Message Peter Eisentraut 2022-01-07 16:14:47 Re: Add 64-bit XIDs into PostgreSQL 15