From: | Hans Schou <hans(dot)schou(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Deadlock with one table - PostgreSQL is doing it right |
Date: | 2017-12-21 10:37:05 |
Message-ID: | CAApBw36hmDPXTN44Fxx=CCgTgf+-iDsBzNOTtnF-QaCfAOSncQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi
FYI - if it has any interest
During my preparation for describing what happens when two processes update
the same row in a table, I came across that PostgreSQL is doing right and
Oracle is doing it wrong.
The situation is a process which get a deadlock, but because it is a
script, it sends a commit anyway. This is bad behavior by humans but that's
how they are.
After both processes commit's the table should be:
i | n
---+---
1 | 11
2 | 21
in Oracle it is:
i | n
---+---
1 | 11
2 | 22
PostgreSQL: https://youtu.be/rH-inFRMcvQ
Oracle: https://youtu.be/l2IGoaWql64
PostgreSQL:
A
select * from t;
begin;
update t set n=n+1 where i=2;
B
begin;
update t set n=n+1 where i=1;
update t set n=n+1 where i=2;
A
update t set n=n+1 where i=1;
B
commit;
A
commit;
best regards
hans
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2017-12-21 11:08:37 | Re: psycopg2 and java gssapi questions |
Previous Message | Olivier Macchioni | 2017-12-21 10:34:22 | Dynamic Enum? |