Fast seralizable transactions starving slower ones

From: Viktor Fougstedt <viktor(at)chalmers(dot)se>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Fast seralizable transactions starving slower ones
Date: 2018-06-07 05:45:05
Message-ID: 84A17190-EC3D-43BC-BCA6-7E288023AAC9@chalmers.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello!

We have a system with a lot of integrity constraints that are not easily expressed as SQL constraints. We therefore run all writing transactions in serializable isolation, so that our code can make SELECT:s to check the constraints.

We’ve run in to a, well, it’s not a “problem”, because everything is working according to spec. But some of our transactions are much quicker than the other. Since the first COMMIT of colliding seralizable transactions always wins, the shorter transactions starve the slower ones, which are always restarted.

We’re now working on a solution where all transactions start by taking an advisory lock. Normally transactions release it immediately, but a transaction which has been restarted multiple times will keep it, preventing any others from starting. Thereby it will run to completion, normally within a maximum of one more restart.

Are there any other solutions to this starvation problem?

Regards,
/Viktor

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2018-06-07 07:00:29 Re: Code of Conduct plan
Previous Message Jan Claeys 2018-06-07 00:14:48 Re: Code of Conduct plan