Re: [HACKERS] Error: dsa_area could not attach to a segment thathas been freed
От | Gaddam Sai Ram |
---|---|
Тема | Re: [HACKERS] Error: dsa_area could not attach to a segment thathas been freed |
Дата | |
Msg-id | 15e9dec5358.f19835f310045.8997056759328389356@zohocorp.com обсуждение исходный текст |
Ответ на | Re: [HACKERS] Error: dsa_area could not attach to a segment that hasbeen freed (Thomas Munro <thomas.munro@enterprisedb.com>) |
Ответы |
Re: [HACKERS] Error: dsa_area could not attach to a segment that hasbeen freed
|
Список | pgsql-hackers |
Thank you very much! That fixed my issue! :)
I was in an assumption that pinning the area will increase its lifetime but yeah after taking memory context into consideration its working fine!
I was in an assumption that pinning the area will increase its lifetime but yeah after taking memory context into consideration its working fine!
Regards
G. Sai Ram
---- On Wed, 20 Sep 2017 11:16:19 +0530 Thomas Munro <thomas.munro@enterprisedb.com> wrote ----
On Fri, Sep 15, 2017 at 7:51 PM, Gaddam Sai Ram<gaddamsairam.n@zohocorp.com> wrote:> As i'm pinning the dsa mapping after attach, it has to stay through out the> backend session. But not sure why its freed/corrupted.>> Kindly help me in fixing this issue. Attached the copy of my extension,> which will reproduce the same issue.Your DSA area is pinned and the mapping is pinned, but there is onemore thing that goes away automatically unless you nail it to thetable: the backend-local dsa_area object which dsa_create() anddsa_attach() return. That's allocated in the "current memorycontext", so if you do it from your procedure simple_udf_func withoutmaking special arrangements it gets automatically freed at end oftransaction. If you're going to cache it for the whole life of thebackend, you'd better make sure it's allocated in memory context thatlives long enough. Where you have dsa_create() and dsa_attach()calls, try coding like this:MemoryContext old_context;old_context = MemoryContextSwitchTo(TopMemoryContext);area = dsa_create(...);MemoryContextSwitchTo(old_context);old_context = MemoryContextSwitchTo(TopMemoryContext);area = dsa_attach(...);MemoryContextSwitchTo(old_context);You'll need to #include "utils/memutils.h".--Thomas Munro
В списке pgsql-hackers по дате отправления: