pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: torikoshia <torikoshia@oss.nttdata.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Georgios Kokolatos <gkokolatos@protonmail.com>
Cc: Kasahara Tatsuhito <kasahara.tatsuhito@gmail.com>
Cc: craig@2ndquadrant.com
Subject: Re: Get memory contexts of an arbitrary backend process
Date: Thu, 04 Mar 2021 18:32:33 +0900
Message-ID: <9a50371e15e741e295accabc72a41df1@oss.nttdata.com> (raw)
In-Reply-To: <40c1a4b19ad03beacee2642a3cd61c14@oss.nttdata.com>
References: <0271f440ac77f2a4180e0e56ebd944d1@oss.nttdata.com>
	<270ec80dbbebfb5c6f2b9fdd7a7858b5@oss.nttdata.com>
	<160502083340.7362.4386116585349115146.pgcf@coridan.postgresql.org>
	<064d510f2d33edc37dfd6b8f3b6bd30e@oss.nttdata.com>
	<d42d3186-d647-9af4-7c1c-d6ffca8bff40@oss.nttdata.com>
	<1685539.1606959410@sss.pgh.pa.us>
	<83ff0aff04fffc95cbd1fc1637a0fccc@oss.nttdata.com>
	<28e1feb71b94ac9918830bc4a0c1844f@oss.nttdata.com>
	<CAP0=ZV+XcPnX+m9ROG07hs=DqwQCOLAojgvYCRogw=bFAv1+Eg@mail.gmail.com>
	<9a59401241e9269254e70c8e0ef1cc7a@oss.nttdata.com>
	<4ae7b086a5b49fdfec7c1154d6fc7a40@oss.nttdata.com>
	<40c1a4b19ad03beacee2642a3cd61c14@oss.nttdata.com>

On 2021-01-14 19:11, torikoshia wrote:
> Since pg_get_target_backend_memory_contexts() waits to dump memory and
> it could lead dead lock as below.
> 
>   - session1
>   BEGIN; TRUNCATE t;
> 
>   - session2
>   BEGIN; TRUNCATE t; -- wait
> 
>   - session1
>   SELECT * FROM pg_get_target_backend_memory_contexts(<pid of session
> 2>); --wait
> 
> 
> Thanks for notifying me, Fujii-san.
> 
> 
> Attached v8 patch that prohibited calling the function inside 
> transactions.

Regrettably, this modification could not cope with the advisory lock and
I haven't come up with a good way to deal with it.

It seems to me that the architecture of the requestor waiting for the
dumper leads to this problem and complicates things.


Considering the discussion printing backtrace discussion[1], it seems
reasonable that the requestor just sends a signal and dumper dumps to
the log file.

Since I found a past discussion that was doing exactly what I thought
reasonable[2], I'm going to continue that discussion if there are no
objections.


Any thought?


[1] 
https://www.postgresql.org/message-id/flat/CALDaNm3ZzmFS-=r7oDUzj7y7BgQv+N06Kqyft6C3xZDoKnk_6w@mail....
[2] 
https://www.postgresql.org/message-id/flat/20171212044330.3nclev2sfrab36tf%40alap3.anarazel.de#6f28b...


Regards,

--
Atsushi Torikoshi
NTT DATA CORPORATION





view thread (52+ messages)  latest in thread

Message-ID: <9a50371e15e741e295accabc72a41df1@oss.nttdata.com>
Permalink:  ../9a50371e15e741e295accabc72a41df1@oss.nttdata.com/
Also on:    postgresql.org/message-id/9a50371e15e741e295accabc72a41df1@oss.nttdata.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: torikoshia@oss.nttdata.com, tgl@sss.pgh.pa.us, masao.fujii@oss.nttdata.com, gkokolatos@protonmail.com, kasahara.tatsuhito@gmail.com, craig@2ndquadrant.com
  Subject: Re: Get memory contexts of an arbitrary backend process
  In-Reply-To: <9a50371e15e741e295accabc72a41df1@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox