spock
Multi-master logical replication extension for PostgreSQL
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
spock | 5.0.5 | ETL | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 9560 | spock | Yes | Yes | Yes | Yes | No | No | spock |
| Related | lolor snowflake |
|---|
works on pgedge kernel fork
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 5.0.5 | 1817161514 | spock | - |
| RPM | PIGSTY | 5.0.5 | 1817161514 | spock_$v | pgedge_$v |
| DEB | PIGSTY | 5.0.5 | 1817161514 | pgedge-$v-spock | pgedge-$v |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY MISS | PIGSTY 5.0.5 el8.x86_64.pg17 : spock_17 spock_17-5.0.5-1PIGSTY.el8.x86_64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el8.aarch64 | PIGSTY MISS | PIGSTY 5.0.5 el8.aarch64.pg17 : spock_17 spock_17-5.0.5-1PIGSTY.el8.aarch64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el9.x86_64 | PIGSTY MISS | PIGSTY 5.0.5 el9.x86_64.pg17 : spock_17 spock_17-5.0.5-1PIGSTY.el9.x86_64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el9.aarch64 | PIGSTY MISS | PIGSTY 5.0.5 el9.aarch64.pg17 : spock_17 spock_17-5.0.5-1PIGSTY.el9.aarch64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el10.x86_64 | PIGSTY MISS | PIGSTY 5.0.5 el10.x86_64.pg17 : spock_17 spock_17-5.0.5-1PIGSTY.el10.x86_64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el10.aarch64 | PIGSTY MISS | PIGSTY 5.0.5 el10.aarch64.pg17 : spock_17 spock_17-5.0.5-1PIGSTY.el10.aarch64.rpm
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d12.x86_64 | PIGSTY MISS | PIGSTY 5.0.5 d12.x86_64.pg17 : pgedge-17-spock pgedge-17-spock_5.0.5-1PIGSTY~bookworm_amd64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d12.aarch64 | PIGSTY MISS | PIGSTY 5.0.5 d12.aarch64.pg17 : pgedge-17-spock pgedge-17-spock_5.0.5-1PIGSTY~bookworm_arm64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d13.x86_64 | PIGSTY MISS | PIGSTY 5.0.5 d13.x86_64.pg17 : pgedge-17-spock pgedge-17-spock_5.0.5-1PIGSTY~trixie_amd64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d13.aarch64 | PIGSTY MISS | PIGSTY 5.0.5 d13.aarch64.pg17 : pgedge-17-spock pgedge-17-spock_5.0.5-1PIGSTY~trixie_arm64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u22.x86_64 | PIGSTY MISS | PIGSTY 5.0.5 u22.x86_64.pg17 : pgedge-17-spock pgedge-17-spock_5.0.5-1PIGSTY~jammy_amd64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u22.aarch64 | PIGSTY MISS | PIGSTY 5.0.5 u22.aarch64.pg17 : pgedge-17-spock pgedge-17-spock_5.0.5-1PIGSTY~jammy_arm64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u24.x86_64 | PIGSTY MISS | PIGSTY 5.0.5 u24.x86_64.pg17 : pgedge-17-spock pgedge-17-spock_5.0.5-1PIGSTY~noble_amd64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u24.aarch64 | PIGSTY MISS | PIGSTY 5.0.5 u24.aarch64.pg17 : pgedge-17-spock pgedge-17-spock_5.0.5-1PIGSTY~noble_arm64.deb
| PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
Build
You can build the RPM / DEB packages for spock using pig build:
pig build pkg spock # build RPM / DEB packages
Install
You can install spock directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install spock; # Install for current active PG version
pig ext install -y spock -v 17 # PG 17
dnf install -y spock_17 # PG 17
apt install -y pgedge-17-spock # PG 17
Preload:
shared_preload_libraries = 'spock';
Create Extension:
CREATE EXTENSION spock;
Usage
spock: Multi-master logical replication extension for PostgreSQL
Multi-master logical replication for PostgreSQL 15+. Each node acts as both publisher and subscriber.
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
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.