update error with serializable

From: Tom DalPozzo <t(dot)dalpozzo(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: update error with serializable
Date: 2017-01-20 10:44:32
Message-ID: CAK77FCRsGQOe+cZk-dATme5Ub7EE9G-YUXvPqhr6A5=q70oA4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I've two threads countinuously updataing rows in the same table.
Each one does: BEGIN, UPDATE,UPDATE,,,,COMMIT
There can't be two active transactions updating the same row (my bug apart
but I don't think so).
I'm using default_transaction_isolation = 'serializable'
I get "could not serialize access due to read/write dependencies among
transactions"
I din't expect to see it, hence there must be something in postgresql
theory that I haven't understood well and I'd like a clarification.

Below here a log of commands issued by my threads followed by the error msg
from PG server.

Thanks
Pupillo

Log:
thread 0: BEGIN
thread 1: BEGIN
thread 0: UPDATE stato SET dati=$1 WHERE id=0;
thread 0: UPDATE stato SET dati=$1 WHERE id=1;
thread 1: UPDATE stato SET dati=$1 WHERE id=10;
thread 0: UPDATE stato SET dati=$1 WHERE id=2;
thread 1: UPDATE stato SET dati=$1 WHERE id=11;
thread 1: UPDATE stato SET dati=$1 WHERE id=12;
thread 0: UPDATE stato SET dati=$1 WHERE id=3;
thread 1: UPDATE stato SET dati=$1 WHERE id=13;
thread 0: UPDATE stato SET dati=$1 WHERE id=4;
thread 1: UPDATE stato SET dati=$1 WHERE id=14;
thread 0: UPDATE stato SET dati=$1 WHERE id=5;
thread 1: UPDATE stato SET dati=$1 WHERE id=15;
thread 1: UPDATE stato SET dati=$1 WHERE id=16;
thread 0: UPDATE stato SET dati=$1 WHERE id=6;
thread 1: UPDATE stato SET dati=$1 WHERE id=17;
thread 0: UPDATE stato SET dati=$1 WHERE id=7;
thread 1: UPDATE stato SET dati=$1 WHERE id=18;
thread 1: UPDATE stato SET dati=$1 WHERE id=19;
thread 0: UPDATE stato SET dati=$1 WHERE id=8;
thread 0: UPDATE stato SET dati=$1 WHERE id=9;
thread 1: COMMIT
thread 0:UPDATE ERROR

ERROR: could not serialize access due to read/write dependencies among
transactions
DETAIL: Reason code: Canceled on identification as a pivot, during
conflict out checking.
HINT: The transaction might succeed if retried.
STATEMENT: UPDATE stato SET dati=$1 WHERE id=9;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Michel Scheiwiler 2017-01-20 14:35:45 Start/stop postgresql with pg_ctl or service without root access on RHEL
Previous Message Adrian Klaver 2017-01-19 21:08:11 Re: factor effecting performance of postgres