Help needed in using 'on_dsm_detach' callback - Mailing list pgsql-hackers

From Gaddam Sai Ram
Subject Help needed in using 'on_dsm_detach' callback
Date
Msg-id 16127197919.10f81dae25294.1575119220821003425@zohocorp.com
Whole thread Raw
Responses Re: Help needed in using 'on_dsm_detach' callback  (Thomas Munro <thomas.munro@enterprisedb.com>)
List 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->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


pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] Subscription code improvements
Next
From: Masahiko Sawada
Date:
Subject: Re: Regarding ambulkdelete, amvacuumcleanup index methods