From: | Aditya Gupta <adgupta1003(at)gmail(dot)com> |
---|---|
To: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Unexpected Null Pointer For Static Shared Memory Segment |
Date: | 2024-07-27 00:30:09 |
Message-ID: | CH3PR10MB7834D2B5AAA7C599DB321E17F1B52@CH3PR10MB7834.namprd10.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2024-07-27 03:27:08 | Re: Slow performance |
Previous Message | Fatih Sazan | 2024-07-26 09:40:53 | Re: Slow performance |