Re: BUG #12330: ACID is broken for unique constraints

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: Nikita Volkov <nikita(dot)y(dot)volkov(at)mail(dot)ru>, Greg Stark <stark(at)mit(dot)edu>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BUG #12330: ACID is broken for unique constraints
Date: 2014-12-30 16:15:15
Message-ID: CAHyXU0xp5eUzUv2VsV65Xa6i-90p9K0JBZ3DO-te_migJRBwPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, Dec 29, 2014 at 3:53 PM, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
>> I tend to build out applications on top of functions and the
>> inability to set isolation mode inside a function confounds me
>> from using anything but 'read committed'.
>
> Hey, no problem -- just set default_transaction_isolation =
> 'serializable' in your postgresql.conf file and never override
> isolation level and you'll never have to use an explicit table lock
> or SELECT FOR UPDATE again. While you're at it, set
> default_transaction_read_only = on and only override it for
> transactions that (might) need to update and you'll have dodged the
> worst of the performance problems from serializable transactions.

ok...wow. That's pretty convincing, honestly. Your objective is
sensible and clear.

So basically there are/were two concrete concerns: compatibility
break and loss of reported detail. You've convinced me that
principled serialization code shouldn't be impacted negatively by
changing the returned sqlstate (although, perhaps, we're being a bit
too cavalier in terms of the amount of unprincipled code out there --
particularly looping pl/pgsql exception handlers).

Ideally, you'd sneak more detail about the specifics of the error into
errdetail or someplace as Jim is suggesting. That'd address the other
point. So, given those things, I'm mollified, FWIW.

As an aside, the main reason I don't run with serializable isn't
performance paranoia or OCD management of locking semantics in the
90%+ of code that doesn't need that treatment; it's because I build
code (well, chaining DML and such) in the server, always, and have no
way of managing isolation level inside of functions because by the
time the function body is invoked the snapshot is already generated.
I can make read committed transactions work with appropriate locking
but there is no way to downgrade serializable transactions in flight.
IOW, lack of proper stored procedures is what's holding me back.

merlin

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Greg Stark 2014-12-30 17:24:18 Re: BUG #12330: ACID is broken for unique constraints
Previous Message ijbalazs 2014-12-30 07:39:35 Re: BUG #11039: installation fails when trying to install C++ redistributable

Browse pgsql-hackers by date

  From Date Subject
Next Message David Johnston 2014-12-30 16:21:39 Re: [HACKERS] ON_ERROR_ROLLBACK
Previous Message Abhijit Menon-Sen 2014-12-30 16:06:19 Re: What exactly is our CRC algorithm?