Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-22 Thread Mahendranath Gurram
Hi Thomas, When you create or attach to a DSA area, a detach callback is automatically registered on the control segment (or containing segment, for an in-place DSA area). See the code like this in dsa.c: /* Clean up when the control segment detaches. */ on_dsm_detach(segment, &dsa_on_

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-22 Thread Thomas Munro
On Thu, Jun 22, 2017 at 10:59 PM, Mahendranath Gurram wrote: > I'm implementing the In-Memory index as per your suggestion. So far it's > good. Great news. > As of now, only one thing is unclear for me. How could i detach the > dsa(dsa_detach() call) in backend (typically during backend quit). >

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-22 Thread Mahendranath Gurram
Hi Thomas, I'm implementing the In-Memory index as per your suggestion. So far it's good. As of now, only one thing is unclear for me. How could i detach the dsa(dsa_detach() call) in backend (typically during backend quit). Of-course when process quits, all it's associated memory will be

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-21 Thread Mahendranath Gurram
Hi Thomas, I like the whole idea. In fact, i understood this in your very first response itself. Only thing is every time i have to check for dsa_attached or not. I mean get_my_shared_state() is NULL or not. To avoid that check, i tried creating it in _PG_Init(postmaster process itself) a

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-20 Thread Thomas Munro
On Wed, Jun 21, 2017 at 5:27 PM, Mahendranath Gurram wrote: > Initially i tried to design the same way. > I mean, i have created a background worker and created dsa in it. > I tried to attach/detach to the same dsa/dsm by all the backends(postgres > clients/connections) during backend(client/conne

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-20 Thread Mahendranath Gurram
Hi Thomas, Thanks for taking time and explaining the things. Postgres extensions can't rely on backends inheriting the postmaster's memory map like this (other than the main shared memory areas which the core code looks after). For one thing, new backends aren't created with fork() on all

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-20 Thread Thomas Munro
On Sat, Jun 17, 2017 at 1:17 AM, Mahi Gurram wrote: >> 3. Whether you are the backend that created it or a backend that >> attached to it, I think you'll need to store the dsa_area in a global >> variable for your UDFs to access. Note that the dsa_area object will >> be different in each backend

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-20 Thread Dilip Kumar
On Tue, Jun 20, 2017 at 6:48 PM, Mahendranath Gurram wrote: > The steps you followed are right. May i know in which OS you tried? > Mac/Linux. > > Because, In Mac, it is working fine. just as expected. But the > problem(segmentation fault) I'm facing is with linux systems. Mine is Linux. CentOS

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-20 Thread Mahendranath Gurram
Hi Dilip, Thanks for your response. The steps you followed are right. May i know in which OS you tried? Mac/Linux. Because, In Mac, it is working fine. just as expected. But the problem(segmentation fault) i'm facing is with linux systems. Thanks & Best Regards, -Mahi Teamwork divide

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-20 Thread Dilip Kumar
On Tue, Jun 20, 2017 at 3:16 PM, Mahendranath Gurram wrote: > Hi Thomas, > > Any update on this? > > Please let me know how can i proceed further. > > Thanks & Best Regards, > -Mahi I did not see the code but just tested with your code. 1) Added test_dsa to shared preload library. 2) CREATE EXTE

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-20 Thread Mahendranath Gurram
Hi Thomas, Any update on this? Please let me know how can i proceed further. Thanks & Best Regards, -Mahi On Fri, 16 Jun 2017 18:47:37 +0530 Mahi Gurram wrote Hi Thomas, Thanks for your response and suggestions to change the code. Now i

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-06-15 Thread Thomas Munro
On Thu, Jun 15, 2017 at 6:32 PM, Mahi Gurram wrote: > Followed the same as per your suggestion. Refer the code snippet below: > >> void >> _PG_init(void){ >> RequestAddinShmemSpace(1); >> PreviousShmemHook = shmem_startup_hook; >>shmem_startup_hook = BufferShmemHook; >> } >

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-05-27 Thread Thomas Munro
On Tue, May 23, 2017 at 10:42 PM, Mahi Gurram wrote: > Hello everyone, > > I'm building In-Memory index extension for Postgres, for which i'm trying to > use DSA. But ended with some issues, as it is not allowing me to create > DSA(Dynamic Shared Area) in _PG_init function. > > Please refer my_PG_

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-05-26 Thread Amit Kapila
On Wed, May 24, 2017 at 11:39 AM, Mahi Gurram wrote: > One solution that is striking me is > 1. I'll create one background worker and will initialise DSA in it. > 2. If there are any callbacks available for client open/close connections, > i'll attach/detach to the DSA in those callbacks. > >

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-05-23 Thread Mahi Gurram
One solution that is striking me is 1. I'll create one background worker and will initialise DSA in it. 2. If there are any callbacks available for client open/close connections, i'll attach/detach to the DSA in those callbacks. But i'm not sure there are such callbacks available. If such call

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-05-23 Thread Mahi Gurram
Hi, As Michael said, i'm creating DSA too early. Shared_Preload libraries are loading prior to memory related stuff. But i'm totally clueless how to solve my use case. Please help me with any work around. Thanks & Best Regards, - Mahi On Tue, May 23, 2017 at 5:52 PM, Mahi Gurram wrote: > Hi

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-05-23 Thread Mahi Gurram
Hi Michael, Thanks for your response. All i'm building is In-Memory Index as an extension over Postgres. Postgres Indexes will get Insert calls and Read calls from various processes(typically client/connection process - forked processes to postmaster process). Hence i have to maintain my In-Memo

Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-05-23 Thread Michael Paquier
On Tue, May 23, 2017 at 6:42 AM, Mahi Gurram wrote: > I'm building In-Memory index extension for Postgres, for which i'm trying to > use DSA. But ended with some issues, as it is not allowing me to create > DSA(Dynamic Shared Area) in _PG_init function. > > Please refer my_PG_init code below: >> >

[HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)

2017-05-23 Thread Mahi Gurram
Hello everyone, I'm building In-Memory index extension for Postgres, for which i'm trying to use DSA. But ended with some issues, as it is not allowing me to create DSA(Dynamic Shared Area) in _PG_init function. Please refer my_PG_init code below: > void > _PG_init(void) > { > area = dsa_create(