Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j7UAu-0003iW-6F for pgsql-general@arkaria.postgresql.org; Fri, 28 Feb 2020 01:10:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j7UAs-0000jQ-0p for pgsql-general@arkaria.postgresql.org; Fri, 28 Feb 2020 01:10:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j7UAq-0000jJ-Qo for pgsql-general@lists.postgresql.org; Fri, 28 Feb 2020 01:10:41 +0000 Received: from sonic305-21.consmr.mail.sg3.yahoo.com ([106.10.241.84]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j7UAi-0006tH-FU for pgsql-general@lists.postgresql.org; Fri, 28 Feb 2020 01:10:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1582852228; bh=R9FPHxASu3b1waLZqMdKD7ShD3FYQjnS2fPLRtDwZQM=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=Bqu/uPQ06/QoSxUy/AFZm3tasqgmxKUIYQGctFQQiWFnl0FT25GXpoFSk0M+3JaFtf5el6oak4KOywMqRFMBbsSMMb2BFnx/eHXTLzNGdzpRFiqOsjVKEva2SVF8f6mAVQPw5MY6wAE3PNR7VtdzAsoYmFl9nmqlhwuWuN3nsqHEjjezvDfAJEXzfaIaMObJ0j2uNJDgrlPmxtEG5jZMIhkfKi1wH6BMqkMZjOx+zYXkeXC36Fn9JQ+leyhB1GzDUmmgi3hWcsQeIpn+47EggyHW4DMOlZhbpz43wJjdcnE2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ytx6L8M8mmP3413aRz4II5kl.bLUgcD551 7HqryasqUsaHJpfkURLk7iCL9zGHfSl61WO9mMExVuR3ehfX3yt7xk97nov04DBnTWqBT6msPuce OeKPoh_iU2LfzyewDkP3SxBP5to5sE0JqDuF5aaM.4KzE0REKHczGc_MnY94jyo6dZ9YdlHUpbpW 9jKPUoXB_l_GK1mXvToNyLAVFN8AVvP2L2WYs9GXvXAwBvaBKqwR6Y4Pcv8fH9vocGpehZ.9kS_F 08n8elqba6Of9kUAbbJwoxexbOX1jzaKtXL3PTaxw3.gTW9PktV_vTQX1r25900yitILNxnH5ynX cWMzSCOuEvvWne6Dor6SIGT9XwVWo5bFhxpwFhzpRvk1_vqhU7Oj5BCmpDET4Md8Szmpk1C.f8O9 fNw8vfWRD Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.sg3.yahoo.com with HTTP; Fri, 28 Feb 2020 01:10:28 +0000 Received: by smtp430.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID cf9f36bff54e5132a9dd855f9596a6d8; Fri, 28 Feb 2020 01:10:21 +0000 (UTC) X-YMail-OSG: HQaMWF0VM1mX04__R.8AN9xglCHkqrQRrKE8aunXvEFhg5ntaEBh.Z_uj3uAk.R LVuplVeh2IVtZAoR6pPUtQE7vVFuoHXUvBbHDhzbC0ufoNzpu9HSjklxqsugNAcgS.wawy2Y699X FRv1juk5vi9bPIlIKlDg2q1P6nzh7gvfLuBt.jRTzdnrVTBIj5i3evLhHSSKysO_fjHH2tv9hedT LggP5jhmljz2YHvUYWYlJINRJ6zm1_S0kntz2zgVlp8VtdAQ0DS3_U1R3kFfW7zssjXwnvTWhGJw qxofykutmMTpiB9JCMAuP8Cun1kdp9R1LFljZZciOLYNYkdRnQMD6rKKE_LiME7TvuG8FJ7Yw9nH Wm3mCFgQyaVeWzZRgpnIJ.t91LguUruPCdZspsEW4KMZq7RzlBiKmekBY2Lay7HLlYYV3N3WvjOi Kodo1Pcv0iOnmy7PO3ZJK3LKGgHFJKW2HuAX5eca5b1I1vANtqjk0wVWhNSyLfdXa4uLN6MwXdVk a2Zw1jKXVBn2N55ZqI1QEx37JEvwPLPO8KbMIHKVzcjXVLBcWhowwwBgBDZtDe3aAzBUhIHhnJ.d Ex9wj5cnL6ZOX2zT6cE.ODpNQ1s8krfpFh8wzge7aKr6q4mdvFQ8kMRDKD2QzcOf7NCBHoaAeU.g 2bQ6BQ4pAYUTTTgBVd0A1ABH592lC9Viif513h41Rl5JLw6BPN8IVZdZ6U67ctjgdMAhjMPVZvGW MBwErNcGiJLvsrEOh.xlRujaHDCA2JHLnThoYzDc6gphyZ1a7_aZp0j7QtJ8ch2khnAgrJ2KoBYo wnUdGilfe2qyoSX48i5x6_CbqnbHRRbgemNdZbsYSnVzeU3qfuvGbb9wdQlqjcnMQDCppdF0.ihW v1X92hQDmzZ9qZlICsxOEUdvV8Qswius1js03b2Hti4n9RFNWp5QfTn2_ab.P.sq3em_q0lcl4Tt 1Qyvz6mm.yxUNcqRyOzRE9JenG.YLwS9ejvhEeYDhOx_8KIytn_LAPiZVC7WTV_iGEaN9CY8wcg_ qGuM2K7dEcWvDObCogHXcVTHq8Y28r6aOYPzi5SHfBRYgGRfvF9Wgj1p_vHhfkhyaCTgQTh_HUyv DIFhyPDvhv97Jrh1qyuYmn2CPylIt.piJkuU65zquQbGBVTLqcmILo5mghYlb1vbZa937NVx6AlU WDsBRqHKBqxzKg98sgsgFfAcFGO25_ozbBJiu5sN4yyKfCpTdvolgBPqV9B29kRQEcY6o64sAPYk T37Ua5LnrKee5N7_MutB_EVA9rr1cJppHJsb2uzOsOwFMyexpjOvb0OC8PHHXdg-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.gq1.yahoo.com with HTTP; Fri, 28 Feb 2020 01:10:20 +0000 Date: Fri, 28 Feb 2020 01:10:16 +0000 (UTC) From: "sivapostgres@yahoo.com" Reply-To: "sivapostgres@yahoo.com" To: Postgresql General Group Message-ID: <1151434427.3100461.1582852216341@mail.yahoo.com> In-Reply-To: References: <1393516227.2562442.1582789296867.ref@mail.yahoo.com> <1393516227.2562442.1582789296867@mail.yahoo.com> <1654972450.2631031.1582803351218@mail.yahoo.com> <72f62e47-689a-351a-a711-6cfb7312d282@wp.pl> <1401820409.2680701.1582810637855@mail.yahoo.com> <561727835.2707508.1582813582038@mail.yahoo.com> Subject: Re: Need to find the no. of connections for a database MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3100460_741766292.1582852216339" X-Mailer: WebService/1.1.15302 YMailNorrin Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36 Content-Length: 10657 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_3100460_741766292.1582852216339 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Then clearly I've misunderstood what advisory lock could do.=C2=A0 =C2=A0W= e used to put locks in SQL server to avoid deadlock situations.=C2=A0 I tho= ught advisory lock is a similar one.=C2=A0 =C2=A0[ New to Postgres ] The report is arrived from around 10 tables out of 300 tables that are in t= he database.=C2=A0 Once we start this process, we need to ensure that no ot= her user could enter any data in those 10 tables, at least for the processi= ng period.=C2=A0 I thought the table lock [ those 10 tables ] will ensure n= o entry.=C2=A0=C2=A0 We have a menu like this in our application Purchase EntrySales EntrySales CancellationReport=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 =C2=A0 Processing report When we enter the Processing report and click process, we need to ensure th= at no one could enter data from Purchase Entry, Sales Entry, Sales Cancella= tion, 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: =20 =20 W dniu 2020-02-27 o=C2=A015:26, sivapostgres@yahoo.com pisze: > Need to lock around 10 tables.=C2=A0 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=20 an "application flow", not database objects. > > > On Thursday, 27 February, 2020, 07:39:13 pm IST, Ireneusz Pluta/wp.pl wrote: > > > W dniu 2020-02-27 o=C2=A014:37, sivapostgres@yahoo.com pisze: > > Hello, > > > > I'm saying isolation will not work out to my requirement.=C2=A0 =C2=A0T= he steps. > > > > 1.=C2=A0 On completion of all entries by all,=C2=A0 say for a day. > > 2.=C2=A0 Lock, so that no one enters any other data. > > 3.=C2=A0 Create a report from the entered data. > > 4.=C2=A0 Create / Modify required entries from the values arrived in th= e report. [ long process ] > > 5.=C2=A0 Once completed, commit all data. > > 6.=C2=A0 Unlock, so that other users can enter data again.=C2=A0 Data e= ntered 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 ste= p 6, make the process work > in the way you expect? > > https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-AD= VISORY-LOCKS > > > > > > > On Thursday, 27 February, 2020, 06:29:00 pm IST, Ireneusz Pluta/wp.pl <= ipluta@wp.pl=20 > > wrote: > > > > > > W dniu 2020-02-27 o=C2=A012:35, sivapostgres@yahoo.com =20 > > pisze: > > > > > > I need to prevent other users from entering any transaction till I fi= nish taking reports from my > > > application.=C2=A0 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 > > > > > > > > > > =20 ------=_Part_3100460_741766292.1582852216339 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Then clearly I've misunderst= ood what advisory lock could do.   We used to put locks in SQL se= rver to avoid deadlock situations.  I thought advisory lock is a simil= ar 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 n= eed to ensure that no other user could enter any data in those 10 tables, a= t least for the processing period.  I thought the table lock [ those 1= 0 tables ] will ensure no entry.  

We have a me= nu like this in our application

Purchase Entry
Sales Entry
Sales Cancellation
Report
   &nb= sp;    Processing report

When we enter the = Processing report and click process, we need to ensure that no one could en= ter data from Purchase Entry, Sales Entry, Sales Cancellation, etc.

Couldn't understand how advisory lock could achieve this?
<= div dir=3D"ltr" data-setdir=3D"false">
Happiness Always
BK= R Sivaprakash

=20
=20
On Thursday, 27 February, 2020, 10:04:12 pm IST, Ireneu= sz 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 loc= ks 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, siva= postgres@yahoo.com <mailto:sivapostgres@yaho= o.com> pisze:
> > Hello,
&= gt; >
> > 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 e= nters 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 a= gain.  Data entered will be for another date.
> &= gt; 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?
>
&= gt; https://www.pos= tgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS<= br clear=3D"none">>
> >
> &= gt;
> > 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 <mail= to:sivapostgres@yahoo.com>> pisze:

>
> >
> > > I need to prevent other u= sers from entering any transaction till I finish taking reports from my
> > > application.  All users will be using th= e same application, from which this report is supposed to
> > > be printed.
> >
&= gt; > >
> > maybe advisory lock is what you n= eed?
> >
> > https://www.postgresql.org/docs/current/ex= plicit-locking.html#ADVISORY-LOCKS
> >
> >
> >
> >=
>
>


------=_Part_3100460_741766292.1582852216339--