You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
\set id random(1, 512)
BEGIN;
-- update #1: random row from table_a_102008 (node 1)UPDATE table_a SET value = value +1WHERE id = (2* :id -1) and shard_n =1;
-- update #2: random row from table_a_102009 (node 1)UPDATE table_a SET value = value -1WHERE id =2* :id and shard_n =2;
COMMIT;
Check sum under pgbench (should always be 0) - always failed
SELECTsum(value) FROM table_a;
The text was updated successfully, but these errors were encountered:
I think I know the problem here. You distribute the table against the column 'shard_n'. (row goes to node1 if it is 1, to node2 if it is 2)
Assumption is that we increment a row and decrement another in each transaction, but this is wrong. id check in WHERE clause could cause no row is updated. Not all ids (random generated) exist in each node.
To fix the problem, you can change the insert query like below (to make sure all id in range (1,1024) exists in both shards):
INSERT INTO table_a (id, shard_n)
SELECT i, 1FROM generate_series(1, 1024) c(i);
INSERT INTO table_a (id, shard_n)
SELECT i, 2FROM generate_series(1, 1024) c(i);
Simple ACID-test (sum calculation under pgbench), PostgreSQL 15.1/Citus 12.1
update.sql:
The text was updated successfully, but these errors were encountered: