Re: Retain dynamic shared memory segments for postmaster lifetime

Поиск
Список
Период
Сортировка
От Amit Kapila
Тема Re: Retain dynamic shared memory segments for postmaster lifetime
Дата
Msg-id CAA4eK1+6Rj2Bmw3aNen4iGH=yZwaYt=2JOjwW0WDWdDswKDh1w@mail.gmail.com
обсуждение исходный текст
Ответ на Retain dynamic shared memory segments for postmaster lifetime  (Amit Kapila <amit.kapila16@gmail.com>)
Ответы Re: Retain dynamic shared memory segments for postmaster lifetime  (Amit Langote <amitlangote09@gmail.com>)
Список pgsql-hackers
On Sun, Jan 12, 2014 at 12:41 PM, Amit Kapila <amit.kapila16@gmail.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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Steeve Lennmark
Дата:
Сообщение: Re: [PATCH] Relocation of tablespaces in pg_basebackup
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: Standalone synchronous master