Help needed in using 'on_dsm_detach' callback

From: Gaddam Sai Ram <gaddamsairam(dot)n(at)zohocorp(dot)com>
To: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Help needed in using 'on_dsm_detach' callback
Date: 2018-01-24 07:37:16
Message-ID: 16127197919.10f81dae25294.1575119220821003425@zohocorp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello people,

We are trying to build an in-memory index in postgres using dsa.

Here is how we implemented dsa part.

We have PROC_DSA_AREA global variable(Process specific DSA Pointer)

We have a piece of traditional postgres shared memory to store dsa_handle

Each process that needs to use DSA, should create/attach DSA (based on dsa_handle stored in shmem)

Once created/attached, set the process dsa pointer to PROC_DSA_AREA variable

Subsequent DSA access in that process will use PROC_DSA_AREA variable with out looking to create/attach

Problem here is, on DSA Detach, i would like to reset PROC_DSA_AREA variable to NULL. Otherwise subsequent DSA calls tries to use the same pointer and may end up into Segmentation Faults. How could i do that?

Found that there is a callback for dsa detach but that function requires segment pointer as an argument, Should be as below:

on_dsm_detach(PROC_DSA_AREA-&gt;segment_maps[0].segment, detach_func);

** detach_func will set PROC_DSA_AREA variable to NULL.

But i couldn't access that segment, as DSA_AREA struct is defined in dsa.c, so I am unable to include.

Any other ways to get dsa detach event, or to access DSA Segment pointer?

Got stuck here.. kindly help me to proceed further.

Thank you,
G. Sai Ram

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2018-01-24 07:54:22 Re: Regarding ambulkdelete, amvacuumcleanup index methods
Previous Message Masahiko Sawada 2018-01-24 07:33:26 Re: [HACKERS] Subscription code improvements