pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sivapostgres@yahoo.com <sivapostgres@yahoo.com>
To: Postgresql General Group <pgsql-general@lists.postgresql.org>
Subject: Re: Need to find the no. of connections for a database
Date: Fri, 28 Feb 2020 01:10:16 +0000 (UTC)
Message-ID: <1151434427.3100461.1582852216341@mail.yahoo.com> (raw)
In-Reply-To: <ad504885-51ed-e356-b821-ec9b73dc0810@wp.pl>
References: <1393516227.2562442.1582789296867.ref@mail.yahoo.com>
	<1393516227.2562442.1582789296867@mail.yahoo.com>
	<C06A448C-51BC-43B9-A0CF-558F28E0090E@gmx.com>
	<1654972450.2631031.1582803351218@mail.yahoo.com>
	<72f62e47-689a-351a-a711-6cfb7312d282@wp.pl>
	<1401820409.2680701.1582810637855@mail.yahoo.com>
	<af11c806-4850-8837-b8ca-89614dc4f49f@wp.pl>
	<561727835.2707508.1582813582038@mail.yahoo.com>
	<ad504885-51ed-e356-b821-ec9b73dc0810@wp.pl>

 Then clearly I've misunderstood what advisory lock could do.   We used to put locks in SQL server to avoid deadlock situations.  I thought advisory lock is a similar one.   [ New to Postgres ]
The report is arrived from around 10 tables out of 300 tables that are in the database.  Once we start this process, we need to ensure that no other user could enter any data in those 10 tables, at least for the processing period.  I thought the table lock [ those 10 tables ] will ensure no entry.  
We have a menu like this in our application
Purchase EntrySales EntrySales CancellationReport        Processing report

When we enter the Processing report and click process, we need to ensure that no one could enter data from Purchase Entry, Sales Entry, Sales Cancellation, etc.
Couldn't understand how advisory lock could achieve this?
Happiness AlwaysBKR Sivaprakash
    On Thursday, 27 February, 2020, 10:04:12 pm IST, Ireneusz Pluta/wp.pl <ipluta@wp.pl> wrote:  
 
 W dniu 2020-02-27 o 15:26, sivapostgres@yahoo.com pisze:
> Need to lock around 10 tables.  Let me try with pg_advisory_lock().

I am not sure why you mention table locks at this point. Just in case: with advisory locks you lock 
an "application flow", not database objects.

>
>
> On Thursday, 27 February, 2020, 07:39:13 pm IST, Ireneusz Pluta/wp.pl <ipluta@wp.pl> wrote:
>
>
> W dniu 2020-02-27 o 14:37, sivapostgres@yahoo.com <mailto:sivapostgres@yahoo.com> pisze:
> > Hello,
> >
> > I'm saying isolation will not work out to my requirement.   The steps.
> >
> > 1.  On completion of all entries by all,  say for a day.
> > 2.  Lock, so that no one enters any other data.
> > 3.  Create a report from the entered data.
> > 4.  Create / Modify required entries from the values arrived in the report. [ long process ]
> > 5.  Once completed, commit all data.
> > 6.  Unlock, so that other users can enter data again.  Data entered will be for another date.
> > Data cannot [should] not entered for the processed date.
> >
> so wouldn't pg_advisory_lock() in step 2, and pg_advisory_unlock() in step 6, make the process work
> in the way you expect?
>
> https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS
>
> >
> >
> > On Thursday, 27 February, 2020, 06:29:00 pm IST, Ireneusz Pluta/wp.pl <ipluta@wp.pl 
> <mailto:ipluta@wp.pl>> wrote:
> >
> >
> > W dniu 2020-02-27 o 12:35, sivapostgres@yahoo.com <mailto:sivapostgres@yahoo.com> 
> <mailto:sivapostgres@yahoo.com <mailto:sivapostgres@yahoo.com>> pisze:
>
> >
> > > I need to prevent other users from entering any transaction till I finish taking reports from my
> > > application.  All users will be using the same application, from which this report is supposed to
> > > be printed.
> >
> > >
> > maybe advisory lock is what you need?
> >
> > https://www.postgresql.org/docs/current/explicit-locking.html#ADVISORY-LOCKS
> >
> >
> >
> >
>
>


  

view thread (14+ messages)  latest in thread

Message-ID: <1151434427.3100461.1582852216341@mail.yahoo.com>
Permalink:  ../1151434427.3100461.1582852216341@mail.yahoo.com/
Also on:    postgresql.org/message-id/1151434427.3100461.1582852216341@mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sivapostgres@yahoo.com
  Subject: Re: Need to find the no. of connections for a database
  In-Reply-To: <1151434427.3100461.1582852216341@mail.yahoo.com>
  References: <1393516227.2562442.1582789296867.ref@mail.yahoo.com> <1393516227.2562442.1582789296867@mail.yahoo.com> <C06A448C-51BC-43B9-A0CF-558F28E0090E@gmx.com> <1654972450.2631031.1582803351218@mail.yahoo.com> <72f62e47-689a-351a-a711-6cfb7312d282@wp.pl> <1401820409.2680701.1582810637855@mail.yahoo.com> <af11c806-4850-8837-b8ca-89614dc4f49f@wp.pl> <561727835.2707508.1582813582038@mail.yahoo.com> <ad504885-51ed-e356-b821-ec9b73dc0810@wp.pl> <1151434427.3100461.1582852216341@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox