Configuration options#
This page documents all configuration options for zodb-pgjsonb, including ZConfig directives, Python constructor parameters, S3 deployment modes, and dependencies.
ZConfig <pgjsonb> section#
The storage is configured in zope.conf via a <pgjsonb> section after
importing the package:
%import zodb_pgjsonb
<zodb_db main>
<pgjsonb>
dsn dbname=zodb host=localhost port=5432 user=zodb password=zodb
</pgjsonb>
</zodb_db>
The factory class is zodb_pgjsonb.config.PGJsonbStorageFactory.
It implements ZODB.storage.
Configuration keys#
Key |
Type |
Default |
Required |
Description |
|---|---|---|---|---|
|
string |
– |
yes |
PostgreSQL connection string in libpq |
|
string |
|
no |
Storage name, used in sort keys. |
|
boolean |
|
no |
Enable history-preserving mode. |
|
string |
(auto-created tempdir) |
no |
Directory for temporary blob files. Auto-created if omitted. |
|
integer |
|
no |
Size of the process-wide shared load cache (L2) in megabytes, shared across all connections in the process. Caches |
|
integer |
|
no |
Size of the per-connection L1 load cache in megabytes, a lock-free hot cache ahead of |
|
integer |
– |
no |
Deprecated since 1.12.0. Alias for |
|
integer |
|
no |
Minimum number of connections in the instance connection pool. Set to |
|
integer |
|
no |
Maximum number of connections in the instance connection pool. |
|
float |
|
no |
Connection pool acquisition timeout in seconds. Raises |
|
integer |
|
no |
Percentage of |
|
float |
|
no |
Per-restart decay factor for historical access scores. |
|
integer |
|
no |
Baseline delay in seconds before the warmer starts, keeping it out of the pod’s cold-start window. Set to |
|
integer |
|
no |
Additional uniform-random delay (0 to |
|
integer |
|
no |
Maximum number of pods warming concurrently cluster-wide, enforced by a PostgreSQL advisory-lock semaphore. Set to a very large value to effectively disable the cap. |
|
integer |
|
no |
Maximum seconds a pod waits for a warming slot before skipping warmup (logs a |
|
integer |
|
no |
Number of object ids fetched per warmer |
|
float |
|
no |
Seconds to pause between warmer batches, lowering per-pod peak query rate. Set to |
|
byte-size |
|
no |
Blobs larger than this value are stored in S3 when S3 is configured. Blobs smaller than this remain in PostgreSQL bytea. Set to |
|
string |
– |
no |
S3 bucket name for large blob storage. If omitted, all blobs are stored in PostgreSQL bytea. |
|
string |
|
no |
S3 key prefix for namespace isolation. |
|
string |
– |
no |
S3 endpoint URL for MinIO, Ceph, or other S3-compatible stores. |
|
string |
– |
no |
AWS region name. |
|
string |
– |
no |
AWS access key ID. Uses the boto3 credential chain if omitted. |
|
string |
– |
no |
AWS secret access key. Uses the boto3 credential chain if omitted. |
|
boolean |
|
no |
Enable SSL for S3 connections. |
|
string |
(falls back to |
no |
Local cache directory for S3 blobs. Recommended for production to avoid repeated S3 downloads. |
|
byte-size |
|
no |
Maximum size of the local blob cache directory. |
Python constructor#
PGJsonbStorage accepts the following parameters:
PGJsonbStorage(
dsn: str,
name: str = "pgjsonb",
history_preserving: bool = False,
blob_temp_dir: str | None = None,
cache_local_mb: int = 16,
pool_size: int = 1,
pool_max_size: int = 10,
pool_timeout: float = 30.0,
s3_client: S3Client | None = None,
blob_cache: S3BlobCache | None = None,
blob_threshold: int = 102_400,
)
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
– |
PostgreSQL connection string. |
|
|
|
Storage name. |
|
|
|
Enable history-preserving mode. |
|
|
|
Blob temp directory. A temporary directory is auto-created when |
|
|
|
Per-instance LRU cache size in megabytes. |
|
|
|
Minimum pool connections. |
|
|
|
Maximum pool connections. |
|
|
|
Pool acquisition timeout in seconds. |
|
|
|
S3 client instance from |
|
|
|
Local S3 blob cache instance from |
|
|
|
Byte threshold for S3 tiering. |
The ZConfig factory (PGJsonbStorageFactory) constructs S3Client and
S3BlobCache from the ZConfig keys before passing them to the constructor.
S3 deployment modes#
Mode |
Configuration |
Blob behavior |
|---|---|---|
PG-only |
|
All blobs stored as PostgreSQL bytea in |
Tiered |
|
Blobs smaller than threshold stored in PG bytea; blobs at or above threshold stored in S3 with key in |
S3-only |
|
All blobs stored in S3. |
Environment variables#
These variables tune startup-DDL coordination across replicas. They are read from the process environment, not from ZConfig.
Variable |
Default |
Description |
|---|---|---|
|
|
|
|
unset |
When set to any non-empty value, bypasses the schema-version gate and forces a full deferred-DDL run under the lock. Use it after a manual index drop or to re-apply DDL that the version markers consider current. |
Added in version 1.14: ZODB_PGJSONB_FORCE_DDL and the schema-version gate it controls.
Dependencies#
Required#
Package |
Purpose |
|---|---|
|
ZODB framework. |
|
Rust/PyO3 pickle-to-JSON transcoder. |
|
PostgreSQL adapter with connection pooling. |
|
Interface declarations. |
|
Transaction management. |
|
Configuration file parsing. |
Optional#
Package |
Extra |
Purpose |
|---|---|---|
|
|
S3 client and blob cache for tiered blob storage. |
|
|
AWS SDK for S3 access. |
Install S3 support with pip install zodb-pgjsonb[s3].