Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Bill Moran
On Wed, 22 Jun 2016 10:20:38 + Sameer Kumar wrote: > On Wed, Jun 22, 2016 at 6:08 PM Vlad Arkhipov wrote: > > > I am running PostgreSQL 9.5. > > > > CREATE TABLE t (id BIGINT NOT NULL PRIMARY KEY, name TEXT); > > > > The constraint that the data must satisfy is `there is no more than 3 > >

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread John R Pierce
On 6/22/2016 3:07 AM, Vlad Arkhipov wrote: CREATE TABLE t (id BIGINT NOT NULL PRIMARY KEY, name TEXT); The constraint that the data must satisfy is `there is no more than 3 records with the same name`. I am not in control of queries that modify the table, so advisory locks can hardly be of

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Jehan-Guillaume de Rorthais
Le Wed, 22 Jun 2016 18:07:46 +0800, Vlad Arkhipov a écrit : > I am running PostgreSQL 9.5. > > CREATE TABLE t (id BIGINT NOT NULL PRIMARY KEY, name TEXT); I guess this is not your definitive definition of the table and you might have some other fields isn't it ? I can see multiple way to chan

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Jehan-Guillaume de Rorthais
Le Wed, 22 Jun 2016 10:49:13 +, Albe Laurenz a écrit : > Sameer Kumar wrote: > > On Wed, Jun 22, 2016 at 6:08 PM Vlad Arkhipov wrote: > >> I am running PostgreSQL 9.5. > >> > >> CREATE TABLE t (id BIGINT NOT NULL PRIMARY KEY, name TEXT); > >> > >> The constraint that the data must satisfy

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Vlad Arkhipov
That is why I need to lock the table before. The transactions are running at the READ COMMITTED isolation level. On 06/22/2016 06:49 PM, Albe Laurenz wrote: But be warned that this will only work if all transactions involved use the isolation level SERIALIZABLE. -- Sent via pgsql-general ma

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Albe Laurenz
Sameer Kumar wrote: > On Wed, Jun 22, 2016 at 6:08 PM Vlad Arkhipov wrote: >> I am running PostgreSQL 9.5. >> >> CREATE TABLE t (id BIGINT NOT NULL PRIMARY KEY, name TEXT); >> >> The constraint that the data must satisfy is `there is no more than 3 >> records with the same name`. >> >> I am no

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Sameer Kumar
On Wed, Jun 22, 2016 at 6:08 PM Vlad Arkhipov wrote: > I am running PostgreSQL 9.5. > > CREATE TABLE t (id BIGINT NOT NULL PRIMARY KEY, name TEXT); > > The constraint that the data must satisfy is `there is no more than 3 > records with the same name`. > > I am not in control of queries that modi

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Vlad Arkhipov
I am running PostgreSQL 9.5. CREATE TABLE t (id BIGINT NOT NULL PRIMARY KEY, name TEXT); The constraint that the data must satisfy is `there is no more than 3 records with the same name`. I am not in control of queries that modify the table, so advisory locks can hardly be of help to me. O

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Albe Laurenz
Vlad Arkhipov wrote: > I have a constraint that requires a table to be locked before checking > it (i.e. no more than 2 records with the same value in the same column). > If I lock the table in the SHARE ROW EXCLUSIVE mode, any vacuuming (or > autovacuuming) process prevents me from checking the co

Re: [GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Sameer Kumar
On Wed, Jun 22, 2016 at 5:10 PM Vlad Arkhipov wrote: > Hello, > > I have a constraint that requires a table to be locked before checking > it (i.e. no more than 2 records with the same value in the same column). > If I lock the table in the SHARE ROW EXCLUSIVE mode, any vacuuming (or > autovacuum

[GENERAL] Protect a table against concurrent data changes while allowing to vacuum it

2016-06-22 Thread Vlad Arkhipov
Hello, I have a constraint that requires a table to be locked before checking it (i.e. no more than 2 records with the same value in the same column). If I lock the table in the SHARE ROW EXCLUSIVE mode, any vacuuming (or autovacuuming) process prevents me from checking the constraint. What a