Skip to content

Upgrading Temporal ​

Hegemony runs Temporal as two images: temporalio/server for the server, and temporalio/admin-tools for two one-shot jobs around it. This page explains what runs at each start, and the one-time step that deployments started on temporalio/auto-setup:1.24.2 need before they run Temporal 1.32.

What runs at each start ​

ServiceImageWhat it does
temporal-schematemporalio/admin-tools:1.32.2Creates the temporal and temporal_visibility databases on postgres-temporal if they are missing, sets up a schema where there is none, and updates both schemas to the version the server needs. Then it exits. It reads the schema versions without writing them, and stops if it cannot read one.
temporaltemporalio/server:1.32.2The server. It starts only after temporal-schema exits successfully.
temporal-namespacetemporalio/admin-tools:1.32.2Waits for the server, and creates the namespace Hegemony runs in (HEGEMONY_TEMPORAL_NAMESPACE, default default) with 168 hours of retention if it does not exist. Then it exits.

Every step can run again safely. A fresh volume gets a new schema, a current database is left as it is, and a restored backup of the same or the previous minor release is updated in place. The temporal service reports healthy only once its namespace answers, so the API, worker and scheduler wait for it.

temporalio/auto-setup did all of this inside the server container. Temporal deprecated that image for production use, and it can no longer be patched: a scan of it lists a brotli library on CISA's Known Exploited Vulnerabilities (KEV) list. auto-setup also added seven sample search attributes (CustomKeywordField and others). Hegemony uses none of them, so new deployments do not get them, and existing ones keep them.

Why a one-time step is needed ​

Temporal supports upgrading its server one minor release at a time. A release can run one-off data migrations when it starts, and a jump across several releases would skip them. Deployments on auto-setup hold Temporal 1.24 data, so they must run 1.25, 1.26, 1.27, 1.28, 1.29, 1.30 and 1.31 once each, in that order, before 1.32.

temporal-schema checks this. When the databases hold a schema older than the one Temporal 1.31 leaves (history 1.19, visibility 1.14), it changes nothing and stops with this message:

text
temporal-schema: these databases were left by a Temporal release more than
  one minor version older than this one, and Temporal must be upgraded one
  minor version at a time. ...

Docker Compose then does not start temporal, and the services that need it wait. The old auto-setup container has already been replaced by then, so Temporal stays down until you run the step below.

It also stops while a run of the step has not finished (see below), with a message that names the release the run stopped in.

Running the step ​

Back up first. Then, from the repository root:

bash
task compose:temporal:upgrade:prod

(task compose:temporal:upgrade:dev for the dev stack.) Without the Taskfile, give the script the Compose command your deployment uses, such as the launcher, from deploy/compose/:

bash
ENV=prod ./temporal/upgrade.sh ./dc.sh

The script:

  1. Reads the schema versions, and works out which release left them.
  2. Stops the temporal server.
  3. For each release from that one to 1.31: records that release, updates the schema with that release's admin-tools, starts that release's server, waits until it is healthy, lets it run for 60 seconds, and stops it.
  4. Clears the record, and tells you to start the stack as usual. temporal-schema then updates the schema to 1.32, and the 1.32 server starts.

It takes a few minutes and pulls 14 images, about 2 GB. The images are pinned by digest in deploy/compose/docker-compose.temporal-upgrade.yml, behind the temporal-upgrade profile, so a normal up never pulls them. Remove them afterwards if you like:

bash
docker image ls 'temporalio/*' --format '{{.Repository}}:{{.Tag}}'

Options ​

Pass options after -- with the Taskfile, or before the Compose command with the script:

  • --from 1.27 starts at that release instead of the one the script would choose. It can go back, but not past a release the databases still need: the script refuses that, and names the latest release you can start at.
  • --settle 120 keeps each server running for 120 seconds instead of 60.

When a run stops part way ​

Fix what it printed, and run the same command again. It resumes in the release it stopped in, even when that release's schema update stopped part way. Running a release again does no harm.

A release's schema update can finish before its server has run, and the schema then looks as if that release were done. So the script records the release it is in on the temporal-upgrade-state volume, and clears it only when the last release has run. While a release is recorded, temporal-schema does not start Temporal, at a reboot or any other start, and says which release to finish.

When the databases are already at the 1.31 schema or later and no release is recorded, the script does nothing.

Restoring an older backup ​

A backup taken before this change holds 1.24 data. Restore it as usual, then run the step before you start the stack. A backup taken on 1.31 or 1.32 needs nothing. If a run of the step had stopped before the restore, run it once more: it steps the restored databases from where they are, and clears the record.

Upgrading Temporal later ​

A later Hegemony release that moves the server to the next minor release changes the server and admin-tools tags together in both compose files, sets TEMPORAL_SCHEMA_MIN_HISTORY to the history schema of the release before it, and adds the release it leaves behind to docker-compose.temporal-upgrade.yml and to STEPS and LEAVES in temporal/upgrade.sh. A deployment that skips Hegemony releases then still reaches the new server by the same command.