HUB
Sign inSign up
partition-runner-postgres logo

stacksaga/partition-runner-postgres

By stacksaga

•Updated 15 days ago

Auto-creates & maintains Postgres range partitions for StackSaga event-stores — zero code.

Image
Databases & storage
0

565

stacksaga/partition-runner-postgres repository overview

⁠StackSaga SQL Partition Runner — PostgreSQL

Docker Image Documentation License

StackSaga SQL Partition Runner (PostgreSQL) automatically creates and maintains the future range partitions of the StackSaga event-store tables (es_transaction, es_transaction_execution_tryout, es_resume_context, es_terminated_transaction) on your PostgreSQL databases.

Instead of building and maintaining a custom Spring Boot application, just run this pre-built image and point it at your databases — no code required. Run one partition runner per database engine; this image is the PostgreSQL one (use stacksaga/partition-runner-mysql for MySQL).


⁠Supported Tags & Flavors

TagBase OSC LibraryRecommended Use
stacksaga/partition-runner-postgres:alpine
stacksaga/partition-runner-postgres:<version>-alpine
Alpine LinuxmuslLightweight: minimal footprint, for local, dev and resource-constrained environments.
stacksaga/partition-runner-postgres:latest
stacksaga/partition-runner-postgres:<version>
Ubuntu JammyglibcProduction: full glibc, broad compatibility.

Images are also published to GitHub Container Registry: ghcr.io/stacksaga/partition-runner-postgres.


⁠Operational Notes

  • UTC clocks: partition date boundaries are computed in the container's time zone. The image pins TZ=Etc/UTC so the "today" and ahead-count partitions never shift by a day across hosts. Keep your database server on UTC too.
  • Privileges: the runner needs CREATE on the target schema (it runs CREATE TABLE … PARTITION OF …). Your application services keep DML-only privileges — only this runner needs DDL rights.
  • Pre-partitioned tables: the event-store tables must already be declared as partitioned parent tables (PARTITION BY RANGE (…)); the StackSaga PostgreSQL reactive support creates them. The runner adds the upcoming declarative child partitions.

⁠Quickstart

⁠1. Persistent daemon (runs on startup, then on a daily cron)
docker run -d --name partition-runner-postgres \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_PAYMENTDB_URL=r2dbc:postgresql://db-host:5432/payment_db \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_PAYMENTDB_USERNAME=partition_admin \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_PAYMENTDB_PASSWORD=secret \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_PAYMENTDB_UNIT=WEEK \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_PAYMENTDB_AHEAD_COUNT=3 \
  stacksaga/partition-runner-postgres:latest

A single runner serves any number of PostgreSQL datasources — add another ..._DATASOURCES_<NAME>_... group per database.

⁠2. One-shot job (Kubernetes CronJob / docker run --rm)
docker run --rm \
  -e STACKSAGA_PARTITIONING_SQL_CRON=none \
  -e STACKSAGA_PARTITIONING_SQL_EXIT_ON_COMPLETION=true \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_PAYMENTDB_URL=r2dbc:postgresql://db-host:5432/payment_db \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_PAYMENTDB_USERNAME=partition_admin \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_PAYMENTDB_PASSWORD=secret \
  stacksaga/partition-runner-postgres:latest

The container runs once, creates the upcoming partitions, and exits 0 on success or 1 on failure.

⁠3. Mounted config file (many datasources)

Mount an application.yml at /app/config/application.yml and keep passwords in env/secrets:

stacksaga:
  partitioning:
    sql:
      datasources:
        paymentdb: { url: "r2dbc:postgresql://db-host:5432/payment_db", username: partition_admin, unit: WEEK,  ahead-count: 3 }
        auditdb:   { url: "r2dbc:postgresql://db-host:5432/audit_db",   username: partition_admin, unit: MONTH, ahead-count: 1 }

⁠Environment Variable Reference

Environment VariablePropertyDefaultDescription
STACKSAGA_PARTITIONING_SQL_ENABLEDstacksaga.partitioning.sql.enabledtrueEnable/disable the runner.
STACKSAGA_PARTITIONING_SQL_CRON…sql.cron0 0 12 * * *Daily schedule. Set to none to disable internal cron (for Kubernetes CronJob).
STACKSAGA_PARTITIONING_SQL_EXIT_ON_COMPLETION…sql.exit-on-completionfalseExit after the startup run (0 success / 1 failure). Set true for one-shot jobs.
STACKSAGA_PARTITIONING_SQL_RUN_ON_STARTUP…sql.run-on-startuptrueCreate partitions immediately on startup.
STACKSAGA_PARTITIONING_SQL_VALIDATE_ON_STARTUP…sql.validate-on-startuptrueTest DB connectivity at startup.
STACKSAGA_PARTITIONING_SQL_VALIDATE_PRIVILEGES…sql.validate-privilegestrueVerify CREATE privileges at startup.
STACKSAGA_PARTITIONING_SQL_CONCURRENCY…sql.concurrency4Datasources processed in parallel.
STACKSAGA_PARTITIONING_SQL_CONNECT_TIMEOUT…sql.connect-timeout10sR2DBC connect timeout.
STACKSAGA_PARTITIONING_SQL_DATASOURCES_<NAME>_URL…datasources.<name>.url—R2DBC URL, e.g. r2dbc:postgresql://host:5432/db.
STACKSAGA_PARTITIONING_SQL_DATASOURCES_<NAME>_USERNAME…<name>.username—DB user with partition privileges.
STACKSAGA_PARTITIONING_SQL_DATASOURCES_<NAME>_PASSWORD…<name>.password—DB password.
STACKSAGA_PARTITIONING_SQL_DATASOURCES_<NAME>_UNIT…<name>.unitDAYSInterval unit: DAYS, WEEK, MONTH, YEAR.
STACKSAGA_PARTITIONING_SQL_DATASOURCES_<NAME>_AHEAD_COUNT…<name>.ahead-count1Future intervals to pre-create.

Use lowercase-alphanumeric datasource names (paymentdb, auditdb) so the env-var mapping is unambiguous.


⁠Documentation & Community

Tag summary
Recent tags
Content type
Image
Digest
sha256:bd40027a1…
Size
126.9 MB
Last updated
15 days ago
docker pull stacksaga/partition-runner-postgres:latest