Unexpected Null Pointer For Static Shared Memory Segment - Mailing list pgsql-general

From Aditya Gupta
Subject Unexpected Null Pointer For Static Shared Memory Segment
Date
Msg-id CH3PR10MB7834D2B5AAA7C599DB321E17F1B52@CH3PR10MB7834.namprd10.prod.outlook.com
Whole thread Raw
List pgsql-general

Hello,

 

I hope this message finds you well. I am currently working on a PostgreSQL extension and have encountered an issue where a static pointer becomes null between different AM routines. My problem is as follows:

 

I am working with a few AM routines, specifically “ambuild” and “amrescan”. During “ambuild”, I use “ShmemInitStruct” to initialize a segment of shared memory and save the pointer to this location in my static, global pointer. I then set some values of the structure that the pointer points to, which I believe works correctly. I have ensured to acquire, and later release, the “AddinShmemInitLock” as well as check if we have found a segment of the same name in shared memory. I can access the pointer and any data I save in the struct perfectly fine during this AM routine. 

 

When the extension later performs “amrescan”, the static pointer I had set is null. I am not quite sure why this is happening. I would greatly appreciate any guidance or suggestions! Perhaps I need to use the startup hooks when calling the “ShmemInitStruct” function (although I would like to avoid this as the size of the segment I am initializing varies at run time) or use dynamic shared memory?

 

Please let me know if there are any more details I can provide or if anything is unclear. This is my first time working on a PostgreSQL extension and asking a question using this mailing list, so please let me know if there is a more appropriate forum I should use.

 

Thanks for your time and assistance!

 

Best,

Aditya Gupta

 

pgsql-general by date:

Previous
From: Fatih Sazan
Date:
Subject: Re: Slow performance
Next
From: David Rowley
Date:
Subject: Re: Slow performance