Skip to content
spock

spock

spock : Multi-master logical replication extension for PostgreSQL

Overview

ID Extension Package Version Category License Language
9570
spock
spock
5.0.10
ETL
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd--
Yes
Yes
Yes
Yes
no
no
Relationships
Schemas spock
See Also
lolor
snowflake

works on pgedge kernel fork

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
5.0.10
18
17
16
15
14
spock -
RPM
PIGSTY
18.4
18
17
16
15
14
pgedge-$v -
DEB
PIGSTY
18.4
18
17
16
15
14
pgedge-$v -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
el8.aarch64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
el9.x86_64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
el9.aarch64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
el10.x86_64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
el10.aarch64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
d12.x86_64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
d12.aarch64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
d13.x86_64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
d13.aarch64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
u22.x86_64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
u22.aarch64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
u24.x86_64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
u24.aarch64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
u26.x86_64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
u26.aarch64
PIGSTY 18.4
PIGSTY 17.10
PIGSTY 16.14
PIGSTY 15.18
N/A
Package Version OS ORG SIZE File URL
pgedge-18 18.4 el8.x86_64 pigsty 13.2 MiB pgedge-18-18.4-1PIGSTY.el8.x86_64.rpm
pgedge-18 18.4 el8.aarch64 pigsty 12.8 MiB pgedge-18-18.4-1PIGSTY.el8.aarch64.rpm
pgedge-18 18.4 el9.x86_64 pigsty 12.1 MiB pgedge-18-18.4-1PIGSTY.el9.x86_64.rpm
pgedge-18 18.4 el9.aarch64 pigsty 11.8 MiB pgedge-18-18.4-1PIGSTY.el9.aarch64.rpm
pgedge-18 18.4 el10.x86_64 pigsty 12.2 MiB pgedge-18-18.4-1PIGSTY.el10.x86_64.rpm
pgedge-18 18.4 el10.aarch64 pigsty 12.0 MiB pgedge-18-18.4-1PIGSTY.el10.aarch64.rpm
pgedge-18 18.4 d12.x86_64 pigsty 10.5 MiB pgedge-18_18.4-1PIGSTY~bookworm_amd64.deb
pgedge-18 18.4 d12.aarch64 pigsty 10.0 MiB pgedge-18_18.4-1PIGSTY~bookworm_arm64.deb
pgedge-18 18.4 d13.x86_64 pigsty 10.5 MiB pgedge-18_18.4-1PIGSTY~trixie_amd64.deb
pgedge-18 18.4 d13.aarch64 pigsty 10.1 MiB pgedge-18_18.4-1PIGSTY~trixie_arm64.deb
pgedge-18 18.4 u22.x86_64 pigsty 11.9 MiB pgedge-18_18.4-1PIGSTY~jammy_amd64.deb
pgedge-18 18.4 u22.aarch64 pigsty 11.7 MiB pgedge-18_18.4-1PIGSTY~jammy_arm64.deb
pgedge-18 18.4 u24.x86_64 pigsty 11.7 MiB pgedge-18_18.4-1PIGSTY~noble_amd64.deb
pgedge-18 18.4 u24.aarch64 pigsty 11.6 MiB pgedge-18_18.4-1PIGSTY~noble_arm64.deb
pgedge-18 18.4 u26.x86_64 pigsty 11.8 MiB pgedge-18_18.4-1PIGSTY~resolute_amd64.deb
pgedge-18 18.4 u26.aarch64 pigsty 11.5 MiB pgedge-18_18.4-1PIGSTY~resolute_arm64.deb

Source

pig build pkg spock;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install spock;		# install via package name, for the active PG version

pig install spock -v 18;   # install for PG 18
pig install spock -v 17;   # install for PG 17
pig install spock -v 16;   # install for PG 16
pig install spock -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'spock';

Create this extension with:

CREATE EXTENSION spock;

Usage

Sources:

spock provides active-active logical replication for PostgreSQL 15 through 18. Each participating database is a Spock node; a multi-master topology is formed by creating directed subscriptions between nodes.

Configuration

In postgresql.conf:

wal_level = 'logical'
max_worker_processes = 10
max_replication_slots = 10
max_wal_senders = 10
shared_preload_libraries = 'spock'
track_commit_timestamp = on
spock.enable_ddl_replication = on
spock.include_ddl_repset = on

Enabling

CREATE EXTENSION spock;

Creating Nodes

On each node, create a node identity:

-- Node 1
SELECT spock.node_create(
    node_name := 'n1',
    dsn := 'host=10.0.0.5 port=5432 dbname=mydb'
);

-- Node 2
SELECT spock.node_create(
    node_name := 'n2',
    dsn := 'host=10.0.0.7 port=5432 dbname=mydb'
);

Creating Subscriptions

For multi-master, each node subscribes to every other node:

-- On n1: subscribe to n2
SELECT spock.sub_create(
    subscription_name := 'sub_n1n2',
    provider_dsn := 'host=10.0.0.7 port=5432 dbname=mydb'
);

-- On n2: subscribe to n1
SELECT spock.sub_create(
    subscription_name := 'sub_n2n1',
    provider_dsn := 'host=10.0.0.5 port=5432 dbname=mydb'
);

Replication Set Management

-- Add table to replication
SELECT spock.repset_add_table('default', 'my_table');

-- Remove table from replication
SELECT spock.repset_remove_table('default', 'my_table');

-- Add all tables in a schema
SELECT spock.repset_add_all_tables('default', '{public}');

Key Features

  • Multi-master (active-active) replication
  • Automatic DDL replication
  • Conflict detection and resolution using commit timestamps
  • Row and column filtering
  • Supports PostgreSQL 15, 16, 17, and 18
  • Tables must have primary keys and matching schemas across nodes

Operations and Caveats

  • Install spock and add it to shared_preload_libraries on every participating server before creating nodes or subscriptions.
  • Keep table definitions, data types, primary keys, and relevant unique indexes identical across nodes. Coordinate DDL even when DDL replication is enabled.
  • Replicated tables need a primary key or another usable replica identity. Temporary and unlogged tables are not replication targets.
  • Spock operates per database. Repeat extension and topology setup for each database that participates.
  • Active-active conflict handling depends on commit timestamps and policy. Test simultaneous inserts and updates, especially nullable unique keys, before production use.
  • Upstream documents platform/build requirements in the README; verify that the PostgreSQL build and Spock package used on every node are compatible.

Version 5.0.10

5.0.10 is a patch release in the 5.0 line. Its release notes include fixes for unique indexes containing NULL, NULLS NOT DISTINCT conflict handling, refreshing cached index metadata after an index is dropped, exception-path memory handling, and numerical version checks used during rolling patch upgrades. Upgrade every node to a compatible patch level and validate subscriptions after the rolling change.

Last updated on