spock
spock
spock : Multi-master logical replication extension for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 9560 | spock | spock | 5.0.5 | 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.5 | 18 17 16 15 14 | spock | - |
| RPM | PIGSTY | 5.0.5 | 18 17 16 15 14 | spock_$v | pgedge_$v |
| DEB | PIGSTY | 5.0.5 | 18 17 16 15 14 | pgedge-$v-spock | pgedge-$v |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
el8.aarch64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
el9.x86_64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
el9.aarch64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
el10.x86_64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
el10.aarch64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
d12.x86_64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
d12.aarch64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
d13.x86_64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
d13.aarch64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
u22.x86_64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
u22.aarch64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
u24.x86_64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
u24.aarch64 | MISS | PIGSTY 5.0.5 | MISS | MISS | MISS |
Source
pig build pkg spock; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install spock; # install via package name, for the active PG version
pig install spock -v 17; # install for PG 17Config this extension to shared_preload_libraries:
shared_preload_libraries = 'spock';Create this extension with:
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 = onEnabling
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
Last updated on