Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-11 Thread Geoff Winkless
On 10 October 2016 at 14:49, Merlin Moncure wrote: > MVCC rules (which DDL generally fall under) try to interleave work as > much as possible which is the problem you're facing. Mmff. Yes, that exposes a fundamental misunderstanding on my part: I had thought that under MVCC things were done indep

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-10 Thread Merlin Moncure
On Thu, Oct 6, 2016 at 4:21 AM, Geoff Winkless wrote: > Hi > > I have code that does (inside a single transaction) > > DROP TABLE IF EXISTS mytable; CREATE TABLE mytable > > Occasionally this produces > > ERROR: duplicate key value violates unique constraint > "pg_type_typname_nsp_index" DETA

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-10 Thread Geoff Winkless
On 6 October 2016 at 18:33, Tom Lane wrote: > I'm a bit confused about exactly what the context is here. AFAICS, > the fragment you quoted should work as you expect, as long as the > table always exists beforehand. Then, the DROPs serialize the > transactions' access to the table and all is well.

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-10 Thread Geoff Winkless
On 6 October 2016 at 18:25, Adrian Klaver wrote: > I do not see sarcasm, I see someone trying to work through what is a complex > scenario. When someone talks about things "magically working as you think it should" I see sarcasm. Perhaps I misread, in which case I apologise. >> _As far as the tr

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Tom Lane
Geoff Winkless writes: > On 6 October 2016 at 16:47, Kevin Grittner wrote: >> I recommend using a transactional advisory lock to serialize these. > Thanks Kevin, that does seem like the best (although not particularly > pleasant) solution. I'm a bit confused about exactly what the context is he

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Adrian Klaver
On 10/06/2016 09:09 AM, Geoff Winkless wrote: On 6 October 2016 at 16:57, Francisco Olarte wrote: You are contradicting yourself. First you say after the command it must not exist. Then you say to do it at commit time. If it is done at commit time you cannot guarantee it does not exist after th

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Geoff Winkless
On 6 October 2016 at 16:47, Kevin Grittner wrote: > I recommend using a transactional advisory lock to serialize these. Thanks Kevin, that does seem like the best (although not particularly pleasant) solution. Geoff -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Geoff Winkless
On 6 October 2016 at 16:57, Francisco Olarte wrote: > You are contradicting yourself. First you say after the command it > must not exist. Then you say to do it at commit time. If it is done at > commit time you cannot guarantee it does not exist after the command. I'm not contradicting myself at

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Francisco Olarte
Geoff: On Thu, Oct 6, 2016 at 5:43 PM, Geoff Winkless wrote: > Nope. Serializable ignores the DROP, and then freezes on CREATE (and > then fails when the first transaction COMMITs). Yep, I tested it too. > Which is also broken, > because the transaction should fail if (at COMMIT time) the table

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Kevin Grittner
On Thu, Oct 6, 2016 at 9:31 AM, Adrian Klaver wrote: > This is how I can trigger the ERROR: > > Session 1: > > test=# begin ; > BEGIN > test=# drop table if exists ddl_test; > NOTICE: table "ddl_test" does not exist, skipping > DROP TABLE > test=# create table ddl_test(id int); > CREATE TABLE >

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Francisco Olarte
Adrian: On Thu, Oct 6, 2016 at 4:31 PM, Adrian Klaver wrote: > This is how I can trigger the ERROR: This is how you can trigger the ISSUE, IMO it is a correct behaviour. Anyway, your example lacks some important details: 1.- SHOW your isolation level. 2.- SHOW your command interleaving. Here i

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Geoff Winkless
On 6 October 2016 at 15:04, Francisco Olarte wrote: > And anyway, what isolation level are you working on? Because it seems > you are using a weaker one than serializable, as I think serializable > should give you more or less what you are expecting ( not on commit > time, but second drop could pr

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Adrian Klaver
On 10/06/2016 02:21 AM, Geoff Winkless wrote: Hi I have code that does (inside a single transaction) DROP TABLE IF EXISTS mytable; CREATE TABLE mytable Occasionally this produces ERROR: duplicate key value violates unique constraint "pg_type_typname_nsp_index" DETAIL: Key (typname, typna

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Francisco Olarte
Hi Geoff: On Thu, Oct 6, 2016 at 1:58 PM, Geoff Winkless wrote: > But surely Transactional DDL implies that (it should appear that) nothing > happens until transaction-commit. That means "drop table if exists" should > drop the table if it exists at commit time, not drop the table if it didn't >

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Geoff Winkless
On 6 Oct 2016 12:06 p.m., "Francisco Olarte" wrote: > > On Thu, Oct 6, 2016 at 11:21 AM, Geoff Winkless wrote: > > DROP TABLE IF EXISTS mytable; CREATE TABLE mytable > > > > Occasionally this produces > > > > ERROR: duplicate key value violates unique constraint > > "pg_type_typname_nsp_inde

Re: [GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Francisco Olarte
On Thu, Oct 6, 2016 at 11:21 AM, Geoff Winkless wrote: > DROP TABLE IF EXISTS mytable; CREATE TABLE mytable > > Occasionally this produces > > ERROR: duplicate key value violates unique constraint > "pg_type_typname_nsp_index" DETAIL: Key (typname, > typnamespace)=(mytable, 2200) already exis

[GENERAL] Transactional-DDL DROP/CREATE TABLE

2016-10-06 Thread Geoff Winkless
Hi I have code that does (inside a single transaction) DROP TABLE IF EXISTS mytable; CREATE TABLE mytable Occasionally this produces ERROR: duplicate key value violates unique constraint "pg_type_typname_nsp_index" DETAIL: Key (typname, typnamespace)=(mytable, 2200) already exists. I can