HUB
Sign inSign up
partition-runner-mysql logo

stacksaga/partition-runner-mysql

By stacksaga

•Updated 15 days ago

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

Image
Databases & storage
0

706

stacksaga/partition-runner-mysql repository overview

⁠StackSaga SQL Partition Runner — MySQL

Docker Image Documentation License

StackSaga SQL Partition Runner (MySQL) 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 MySQL 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 MySQL one (use stacksaga/partition-runner-postgres for PostgreSQL).


⁠Supported Tags & Flavors

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

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


⁠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 ALTER / CREATE on the target schemas (it runs ALTER TABLE … REORGANIZE PARTITION p_max …). Your application services keep DML-only privileges — only this runner needs DDL rights.
  • Pre-partitioned tables: the event-store tables must already be RANGE-partitioned with a p_max catch-all partition (the StackSaga MySQL reactive support creates them). The runner reorganizes p_max into the upcoming dated partitions.

⁠Quickstart

⁠1. Persistent daemon (runs on startup, then on a daily cron)
docker run -d --name partition-runner-mysql \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_ORDERDB_URL=r2dbc:mysql://db-host:3306/order_db \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_ORDERDB_USERNAME=partition_admin \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_ORDERDB_PASSWORD=secret \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_ORDERDB_UNIT=DAYS \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_ORDERDB_AHEAD_COUNT=7 \
  stacksaga/partition-runner-mysql:latest

A single runner serves any number of MySQL 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_ORDERDB_URL=r2dbc:mysql://db-host:3306/order_db \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_ORDERDB_USERNAME=partition_admin \
  -e STACKSAGA_PARTITIONING_SQL_DATASOURCES_ORDERDB_PASSWORD=secret \
  stacksaga/partition-runner-mysql: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:
        orderdb:     { url: "r2dbc:mysql://db-host:3306/order_db",     username: partition_admin, unit: DAYS,  ahead-count: 7 }
        inventorydb: { url: "r2dbc:mysql://db-host:3306/inventory_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 ALTER/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:mysql://host:3306/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 (orderdb, inventorydb) so the env-var mapping is unambiguous.


⁠Documentation & Community

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