From: | Sungwoo Chang <swchangdev(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Fwd: dsm_registry: Add detach and destroy features |
Date: | 2025-06-18 00:03:59 |
Message-ID: | CAAdDe3PQiQGyeRDgWKynpKXVi7nAAWP+o_up8Ji4utKcNA79rw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I created a new patch that throws an exception if we try to call
destroy on a dsm segment that is still in use.
I added a function in dsm.h that returns a refcnt of a given dsm
segment. The destroy function uses that refcnt
getter to check if the dsm segment is in use.
2025년 6월 16일 (월) 오후 11:40, Nathan Bossart <nathandbossart(at)gmail(dot)com>님이 작성:
>
> On Mon, Jun 16, 2025 at 09:02:22AM +0900, Sungwoo Chang wrote:
> > 2025년 6월 14일 (토) 오전 6:50, Nathan Bossart <nathandbossart(at)gmail(dot)com>님이 작성:
> >> Could your use-case be handled with a DSA? On the other thread [0], we're
> >> talking about adding a GetNamedDSA() function, which returns a DSA that you
> >> can use to allocate and free shared memory as needed. In theory you could
> >> even detach the DSA if you no longer needed it in a backend, although
> >> that's probably unnecessary.
> >
> > My use-case requires access to the shared memory object through a named key.
> > Even if we migrate the code to NamedDSA, within the DSA we will need some sort
> > of a map between the named key and the object to access. So, I think NamedDSA
> > won't be the solution.
>
> Right, you'd need some other shared space for the DSA pointers. In the
> other thread, I'm using a dshash table (created via GetNamedDSMHash()) to
> store those for test_dsm_registry [0]. There are probably other ways to do
> this.
>
> > How about when we call destroy, we check if there are other processes
> > attached to it and if so, we throw an exception? I checked C++ boost
> > interprocess library [0], and it looks like that's the way boost does.
> > This way, we can avoid the aforementioned "partitioned" scenario.
>
> That might work.
>
> [0] https://postgr.es/m/aEyX-9k5vlK2lxjz%40nathan
>
> --
> nathan
Attachment | Content-Type | Size |
---|---|---|
v4-0001-add-detach-and-destroy-for-dsm_registry.patch | application/octet-stream | 11.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Fujii Masao | 2025-06-18 00:13:36 | pg_dump misses comments on NOT NULL constraints |
Previous Message | Masahiko Sawada | 2025-06-17 23:07:25 | Re: Proposal: Global Index for PostgreSQL |