Start two local Mimus nodes with Spock 5.0.15, establish bidirectional replication, and verify delta_apply conflict merging.
Initialize two writable nodes
With Spock 5.0.15 installed under /usr/mimus-19, initialize two local instances on ports 5541 (node_a) and 5542 (node_b) with logical WAL and commit timestamps enabled:
for p in 5541 5542;do initdb -D "/tmp/mimus-${p}" --auth-local=trust --auth-host=trust
cat >> "/tmp/mimus-${p}/postgresql.conf"<<EOF
port = ${p}
wal_level = logical
track_commit_timestamp = on
output_plugin_libraries = 'pgoutput,spock_output'
max_worker_processes = 16
max_replication_slots = 10
max_wal_senders = 10
shared_preload_libraries = 'spock'
spock.conflict_resolution = 'last_update_wins'
spock.save_resolutions = on
spock.enable_ddl_replication = off
EOF pg_ctl -D "/tmp/mimus-${p}" -l "/tmp/mimus-${p}.log" start
createdb -p "${p}" lab
done
Create nodes, tables, and bidirectional subscriptions
Create the same table with delta_apply enabled on both nodes, register each Spock node, and wire up subscriptions in both directions:
-- Run on port 5541 (node_a)
CREATEEXTENSIONspock;SELECTspock.node_create('node_a','host=127.0.0.1 port=5541 dbname=lab');CREATETABLEpublic.accounts(idintegerPRIMARYKEY,balanceintegerNOTNULL);ALTERTABLEpublic.accountsALTERCOLUMNbalanceSET(log_old_value=true,delta_apply_function=spock.delta_apply);INSERTINTOpublic.accountsVALUES(1,100);SELECTspock.repset_add_table('default','public.accounts');
-- Run on port 5542 (node_b)
CREATEEXTENSIONspock;SELECTspock.node_create('node_b','host=127.0.0.1 port=5542 dbname=lab');CREATETABLEpublic.accounts(idintegerPRIMARYKEY,balanceintegerNOTNULL);ALTERTABLEpublic.accountsALTERCOLUMNbalanceSET(log_old_value=true,delta_apply_function=spock.delta_apply);SELECTspock.repset_add_table('default','public.accounts');SELECTspock.sub_create('sub_from_a','host=127.0.0.1 port=5541 dbname=lab',replication_sets:=ARRAY['default'],synchronize_structure:=false,synchronize_data:=true,forward_origins:='{}');SELECTspock.sub_wait_for_sync('sub_from_a');
Then add the reverse subscription on node_a (5541) with synchronize_data := false: