DynamoDB DCS backend for Patroni PostgreSQL HA
Project description
Dynatroni (Patroni DynamoDB DCS)
Dynatroni is a DynamoDB-based Distributed Configuration Store (DCS) backend for Patroni PostgreSQL HA.
Features
- DynamoDB as arbiter: leader election via DynamoDB atomic operations
- No quorum requirement: a single surviving node can operate
- AWS-native: IAM auth, managed service
- Cost-effective: pay‑per‑request pricing for small clusters
- Highly available: DynamoDB's built‑in multi‑AZ replication
Docs
- Docs index
- Install & quickstart
- DynamoDB setup
- Configuration & environment
- Multi‑AZ & cold start
- Break‑glass promotion
- Operations & troubleshooting
Installation
pip install dynatroni
DynamoDB Table Setup
Create a DynamoDB table with:
- Partition Key:
cluster_name(String) - Sort Key:
key(String) - TTL attribute:
ttl
aws dynamodb create-table \
--table-name patroni-dynamodb \
--attribute-definitions \
AttributeName=cluster_name,AttributeType=S \
AttributeName=key,AttributeType=S \
--key-schema \
AttributeName=cluster_name,KeyType=HASH \
AttributeName=key,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST
aws dynamodb update-time-to-live \
--table-name patroni-dynamodb \
--time-to-live-specification "Enabled=true,AttributeName=ttl"
Patroni Configuration
In your patroni.yml:
scope: my-cluster
name: node1
dynamodb:
region: us-east-1
table_name: patroni-dynamodb
# Single dial for cost vs responsiveness tradeoff:
# 15s = fast failover, ~24 DynamoDB ops/min
# 60s = balanced (default), ~6 ops/min
# 180s = cost optimized, ~2 ops/min
failover_time: 60
# Optional: for local testing with DynamoDB Local
# endpoint_url: http://localhost:8000
# Timing values are derived from failover_time:
# ttl = failover_time
# loop_wait = failover_time / 3
# retry_timeout = failover_time / 3
# ... rest of patroni config
IAM Permissions
The EC2 instance role needs:
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:Query",
"dynamodb:BatchWriteItem"
],
"Resource": "arn:aws:dynamodb:REGION:ACCOUNT:table/patroni-dynamodb"
}
How It Works
Dynatroni uses DynamoDB as a distributed lock service for PostgreSQL leader election.
Leader Election (Atomic Operations)
All leader operations use conditional writes to ensure exactly one leader:
| Operation | Condition | Guarantees |
|---|---|---|
| Acquire (new cluster) | attribute_not_exists |
Only one node creates the lock |
| Renew (current leader) | session = :mine |
Only the holder can extend |
| Takeover (expired TTL) | ttl < :now |
Only one node wins the race |
| Release (step down) | session = :mine |
Only the holder can release |
The lock has a TTL (default 60s). If not renewed, it expires and another node can take over atomically.
Boundaries
- Single leader guarantee: Conditional writes prevent split-brain
- Leader lease: Bounded by TTL; leader must renew before expiry
- Failure detection:
failover_timebounds how long a dead leader blocks promotion - No fencing tokens: Relies on session IDs and TTL; applications should use PostgreSQL's own fencing
See docs/dynamodb.md for implementation details.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dynatroni-0.1.0.tar.gz.
File metadata
- Download URL: dynatroni-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79fca5cd2be2bffffa92696959c49fbdf2a208d28d07d947bfb58883f9b4cc87
|
|
| MD5 |
b60d805a17b9eefebaabd08ba4912190
|
|
| BLAKE2b-256 |
6861cae0080aca101df7c2c006ec8ecc631c54dbbf31adb9079265da33562175
|
Provenance
The following attestation bundles were made for dynatroni-0.1.0.tar.gz:
Publisher:
publish.yml on SoftOboros/dynatroni
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dynatroni-0.1.0.tar.gz -
Subject digest:
79fca5cd2be2bffffa92696959c49fbdf2a208d28d07d947bfb58883f9b4cc87 - Sigstore transparency entry: 1571893358
- Sigstore integration time:
-
Permalink:
SoftOboros/dynatroni@f5836a160bce02ecb5243b0a7350245706d9720f -
Branch / Tag:
refs/tags/pypi-0.1.0 - Owner: https://github.com/SoftOboros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f5836a160bce02ecb5243b0a7350245706d9720f -
Trigger Event:
push
-
Statement type:
File details
Details for the file dynatroni-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dynatroni-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90a903a0a04f0f52bdb5a0a926476d861695cd10bf61bd60245596bdc874d866
|
|
| MD5 |
83dcc04190feb581871a09cf1e9fd4c6
|
|
| BLAKE2b-256 |
c311c0fae9a563a7e40c0d06194dd7eefec6da5e25ee90a586a03c2f3ea70577
|
Provenance
The following attestation bundles were made for dynatroni-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on SoftOboros/dynatroni
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dynatroni-0.1.0-py3-none-any.whl -
Subject digest:
90a903a0a04f0f52bdb5a0a926476d861695cd10bf61bd60245596bdc874d866 - Sigstore transparency entry: 1571893405
- Sigstore integration time:
-
Permalink:
SoftOboros/dynatroni@f5836a160bce02ecb5243b0a7350245706d9720f -
Branch / Tag:
refs/tags/pypi-0.1.0 - Owner: https://github.com/SoftOboros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f5836a160bce02ecb5243b0a7350245706d9720f -
Trigger Event:
push
-
Statement type: