Re: Retain dynamic shared memory segments for postmaster lifetime

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Retain dynamic shared memory segments for postmaster lifetime
Date: 2014-01-27 14:18:49
Message-ID: CA+HiwqHD0MEpzcvvdoEH7vSeZTUJhHMdODhU4e5FY0fumT65bQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 13, 2014 at 2:50 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> 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.
>
>

Applied dsm_keep_segment_v1.patch and dsm_demo_v1.patch.
Got the following warning when I tried above example:

postgres=# select dsm_demo_create('this message is from session-new', 1);
WARNING: dynamic shared memory leak: segment 1402373971 still referenced
WARNING: dynamic shared memory leak: segment 1402373971 still referenced
dsm_demo_create
-----------------
1402373971
(1 row)

--
Amit

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2014-01-27 14:24:40 Re: Retain dynamic shared memory segments for postmaster lifetime
Previous Message Robert Haas 2014-01-27 14:14:27 Re: What is happening on buildfarm member crake?