From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Retain dynamic shared memory segments for postmaster lifetime |
Date: | 2014-01-13 05:50:33 |
Message-ID: | CAA4eK1+6Rj2Bmw3aNen4iGH=yZwaYt=2JOjwW0WDWdDswKDh1w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Jan 12, 2014 at 12:41 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> Currently there is no way user can keep the dsm
> segments if he wants for postmaster lifetime, so I
> have exposed a new API dsm_keep_segment()
> to implement the same.
>
> The specs and need for this API is already discussed
> in thread:
> http://www.postgresql.org/message-id/CA+TgmoaKoGuJQbEdGeYKYSXud9EAidqx77J2_HXzRgFo3Hr46A@mail.gmail.com
We have decided to bump reference count for segment
and call DuplicateHandle for Windows, but I think it should
also do what dsm_keep_mapping() does that is
ResourceOwnerForgetDSM(), else it will give
Warning: dynamic shared memory leak at transaction end.
> I had used dsm_demo (hacked it a bit) module used
> during initial tests for dsm API's to verify the working on
> Windows. So one idea could be that I can extend
> that module to use this new API, so that it can be tested
> by others as well or if you have any other better way, please
> do let me know.
I have extended test (contrib) module dsm_demo such that now user
can specify during dsm_demo_create the lifespan of segment.
The values it can accept are 0 or 1. Default value is 0.
0 -- means segment will be accessible for session life time
1 -- means segment will be accessible for postmaster life time
The behaviour is as below:
Test -1 (Session life time)
Session - 1
-- here it will create segment for session lifetime
select dsm_demo_create('this message is from session-1', 0);
dsm_demo_create
-----------------
827121111
Session - 2
-----------------
select dsm_demo_read(827121111);
dsm_demo_read
----------------------------
this message is from session-1
(1 row)
Session-1
\q
Session-2
postgres=# select dsm_demo_read(827121111);
dsm_demo_read
---------------
(1 row)
Conclusion of Test-1 : As soon as session which has created segment finished,
the segment becomes non-accessible.
Test -2 (Postmaster life time)
Session - 1
-- here it will create segment for postmaster lifetime
select dsm_demo_create('this message is from session-1', 1);
dsm_demo_create
-----------------
827121111
Session - 2
-----------------
select dsm_demo_read(827121111);
dsm_demo_read
----------------------------
this message is from session-1
(1 row)
Session-1
\q
Session-2
postgres=# select dsm_demo_read(827121111);
dsm_demo_read
---------------
this message is from session-1
(1 row)
Conclusion of Test-2 : a. Segment is accessible for postmaster lifetime.
b. if user restart server, segment is
not accessible.
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
Attachment | Content-Type | Size |
---|---|---|
dsm_demo_v1.patch | application/octet-stream | 4.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2014-01-13 06:28:20 | Re: Standalone synchronous master |
Previous Message | Steeve Lennmark | 2014-01-13 05:13:07 | Re: [PATCH] Relocation of tablespaces in pg_basebackup |