Posgres Concurrency Notes: 2

ERROR:  could not serialize access due to concurrent update
Setup:
CREATE SCHEMA test;
CREATE TABLE test.purchase (id bigint not null);
Process A: BEGIN TRANSACTION ISOLATION LEVEL Repeatable Read;
Process A: INSERT INTO test.purchase(ID) VALUES (10);
Process A: Select sum(ID) From test.purchase where ID between 1 and 100;
Process B: BEGIN TRANSACTION ISOLATION LEVEL Repeatable Read;
Process B: INSERT INTO test.purchase(ID) VALUES (10);
Process B: Select sum(ID) From test.purchase where ID between 1 and 100;
Process B: COMMIT;
Process A: COMMIT;
Process A: COMMIT;
ERROR: could not serialize access due to read/write dependencies among transactions
DETAIL: Reason code: Canceled on identification as a pivot, during commit attempt.
HINT: The transaction might succeed if retried.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Big Tech Cos Finally Create Opportunities for Non-traditional Tech Talent

Lakmé cosmetics customer care number/858482730//858489730/Lakmé cosmetics customer care…

Hurry now it’s still on!

What I’ve learned from building a Wordle clone

Project result

HTTP or Web Sockets for your next Slack bot?

Introducing Text2Summary: Text Summarization on Android ( With TF-IDF )

Hyperledger Fabric Certificate Authority(CA)

Sharing Headers and Footers Across Multi-Page Websites

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
none

none

More from Medium

Beginners guide to authentication and authorization in the Client-Server model.

Types of JWT

Using git in your group projects

How to generate a JWT signing keys