←back to thread

131 points pgedge_postgres | 1 comments | | HN request time: 0.198s | source
Show context
OsrsNeedsf2P ◴[] No.45534696[source]
If both nodes approve an update on the same primary key, what happens? I don't see this crucial detail described in the README
replies(3): >>45534976 #>>45535107 #>>45540386 #
1. bonesmoses ◴[] No.45540386[source]
In Postgres, updates contain the entire row, including all column values. Since the Spock extension follows the "Last Write Wins" model by default, one row version will win, while the other is essentially discarded. This is assuming the update happened on each node _before_ the new value was synchronized over, or essentially simultaneously.

You can address this partially using a CRDT such as the Delta Apply functionality for certain columns:

https://docs.pgedge.com/spock_ext/conflicts

That will only work with numeric-type (INT, BIGINT, NUMERIC, etc.) columns, but effectively merges data so updates work cumulatively.