StackGres provides Change Data Capture (CDC) capabilities through the SGStream custom resource, powered by Debezium Engine.
This allows you to capture database changes in real-time and stream them to various targets.
Before creating an SGStream, ensure you have:
For external PostgreSQL sources, ensure:
wal_level is set to logicalmax_replication_slots is sufficient for your streamsmax_wal_senders allows additional connectionsHere’s a minimal example to stream changes from one SGCluster to another:
apiVersion: stackgres.io/v1alpha1
kind: SGStream
metadata:
name: my-stream
spec:
source:
type: SGCluster
sgCluster:
name: source-cluster
target:
type: SGCluster
sgCluster:
name: target-cluster
pods:
persistentVolume:
size: 1Gi
Apply with:
kubectl apply -f sgstream.yaml
Check the stream status:
kubectl get sgstream my-stream -o yaml
maxRetries setting)The stream execution mode is controlled by the maxRetries field:
| Value | Mode | Description |
|---|---|---|
-1 (default) |
Deployment | Runs indefinitely, automatically restarts on failure |
0 |
Job | Runs once, no retries on failure |
> 0 |
Job | Runs with specified number of retry attempts |
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Source │ │ SGStream Pod │ │ Target │
│ (PostgreSQL) │────▶│ (Debezium) │────▶│ (SGCluster/ │
│ │ │ │ │ CloudEvent/ │
│ │ │ │ │ PgLambda) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │
│ │
▼ ▼
Replication Persistent
Slot + WAL Volume
(Offsets)
Step-by-step guide to creating SGStream resources for CDC operations.
Advanced configuration options for SGStream including Debezium properties.
How to monitor SGStream progress, health, and performance.
Common issues and solutions for SGStream CDC operations.