[GENERAL] Two-phase commit case studies

2017-07-19 Thread Gavin Wahl
Hello, I've read the documentation for two-phase commit and it sounds interesting, but I'm having trouble thinking of how to actually put it into production. How are people using it? Do you use a XA transaction manager or something custom built? How dos the reconciliation work when a component

Re: [GENERAL] Concurrency-safe Replacing a Set of Rows (Without SERIALIZABLE)

2017-04-12 Thread Gavin Wahl
> Given this limited example I'd probably choose to model notifications as an > array on the user table. Then just "UPDATE user SET notifications = > array['a','b']::text WHERE user_id = 1; I'm hesitant to ditch the first normal form just to get around this. Anyway, there's actually extra data

[GENERAL] Concurrency-safe Replacing a Set of Rows (Without SERIALIZABLE)

2017-04-12 Thread Gavin Wahl
I have a table that stores user notifications: CREATE TABLE notifications ( user_id INT, type CHAR(1), PRIMARY KEY (user_id, type) ); When a user edits their notifications, I need to atomically replace the old set with the new set. My first instinct is to do this: BEGIN; DELETE FROM

[GENERAL] SELECT FOR UPDATE violates READ COMMITTED isolation?

2017-04-12 Thread Gavin Wahl
I have this table: CREATE TABLE test (id INT PRIMARY KEY); INSERT INTO test VALUES (1); Then I run these two transactions simultaneously: one| two ---+--- BEGIN; |