Re: Proposal: Add a callback data parameter to GetNamedDSMSegment

Zsolt Parragi <zsolt.parragi@percona.com>

From: Zsolt Parragi <zsolt.parragi@percona.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-04T17:40:21Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Allow passing a pointer to GetNamedDSMSegment()'s init callback.

  2. Move dynamically-allocated LWLock tranche names to shared memory.

> "caller after returning from GetNamedDSHash" <- do you mean
> GetNamedDSMSegment ?

Yes, that was a typo.

> wouldn't the above be sufficient to create a DSM segment containing
> a flexible array?

Yes, it creates it, but can I initialize it properly in
foo_init_state? How can I set the size member to the proper array
size, and how can I zero-initialize the array with the correct length
in it? What I can do currently is:

1. create the lwlock and set size to 0 in foo_init_state
2. take the lwlock after GetNamedDSMSegment returns
3. if size is 0 set it properly and zero-initialize the array

That's why I said that there is a workaround, but it would be nicer if
I could do it properly in the init callback, by passing the array size
as a parameter to it.