Upgrade QueueBox
Copy page
This guide shows how to move a running deployment to a new QueueBox version. It covers the image tag, the database migrations, and the two migrations that need every worker of the old version stopped first.
Read the changelog first
Section titled “Read the changelog first”Read every entry of CHANGELOG.md between your version and the target version. A Breaking section names each change that needs action, and it states the step. The entry also names the migrations that the release ships.
QueueBox follows Semantic Versioning. Below 1.0.0, a MINOR release can carry a breaking change. The changelog then lists it under Breaking.
Pin the image
Section titled “Pin the image”QueueBox ships as a container image for linux/amd64 and linux/arm64. The registry carries three tags for each release:
| Tag | Meaning |
|---|---|
ghcr.io/alternayte/queuebox:0.3.2 |
The exact release. |
ghcr.io/alternayte/queuebox:0.3 |
The newest patch of that MINOR release. |
ghcr.io/alternayte/queuebox:latest |
The newest release. |
Pin the exact version in production. A published tag never moves, so a pinned deployment gets the same image on every pull.
Upgrade with the bundled migrations
Section titled “Upgrade with the bundled migrations”With database.migrate: true, which is the default, QueueBox applies each new migration at startup through Flyway.
- Check that the target release needs no stop of the old workers. See Migrations that need a full stop.
- Change the image tag to the target version.
- Roll the replicas to the new image. The first new replica applies the migrations.
- Check each new replica.
GET /health/readyanswers200, and thequeueboxmetric carries the new version.
curl -s http://localhost:8080/health/readycurl -s http://localhost:8080/metrics | grep '^queuebox{'The Prometheus exporter drops the _info suffix, so the metric queuebox_info appears as queuebox in a scrape. Its version label names the running release.
Upgrade with database.migrate: false
Section titled “Upgrade with database.migrate: false”A deployment whose application user has no DDL rights runs the migrate command of the new image before the new version starts.
-
Check that the target release needs no stop of the old workers. See Migrations that need a full stop.
-
Run the command of the target image with a privileged user. It applies each new migration, logs its version, and exits with 0.
Terminal window docker run --rm \-e QUEUEBOX_DATABASE_URL=jdbc:postgresql://db.internal:5432/queuebox \-e QUEUEBOX_DATABASE_USERNAME=queuebox_admin \-e QUEUEBOX_DATABASE_PASSWORD=secret \ghcr.io/alternayte/queuebox:0.5.0 migrate -
Roll the replicas to the new image.
A custom schema cannot use the command, because the bundled files name the default tables. Apply the same change to your own tables with your own names. Add the new column to the column mapping when you renamed it. See Use custom tables.
A database with files applied by hand
Section titled “A database with files applied by hand”Before 0.5.0, a deployment without DDL rights applied the migration files by hand. Such a database has the QueueBox tables and no Flyway history. From 0.5.0, the start and the migrate command both stop on it with this message:
QueueBox tables exist without a migration history. Run `queuebox migrate --baseline <version>` with the last version you applied by hand.Run the command once with the last version that you applied, for example 10:
docker run --rm \ -e QUEUEBOX_DATABASE_URL=jdbc:postgresql://db.internal:5432/queuebox \ -e QUEUEBOX_DATABASE_USERNAME=queuebox_admin \ -e QUEUEBOX_DATABASE_PASSWORD=secret \ ghcr.io/alternayte/queuebox:0.5.0 migrate --baseline 10The command records V1 to V10 as applied without running them, then applies V11 and every later file. After that, the database is a normal install. The command refuses a database that already has a history, and it changes nothing there.
A new column is nullable or has a default, so the replicas of the previous version keep running against the new schema. Two migrations are exceptions, and the next section covers them.
Migrations that need a full stop
Section titled “Migrations that need a full stop”A migration that changes how a worker claims a row needs a full stop. The old claim and the new claim must never run at the same time. Upgrade in this order:
- Stop every QueueBox replica of the old version.
- Apply the migration.
- Start the replicas of the new version.
V6: the claim token and the lease
Section titled “V6: the claim token and the lease”V6__add_consumption_and_leases.sql adds claim_token and lease_expires_at to both tables. It also adds consumption, scheduled_at, attempt and last_error to the inbox. An old worker fences a claim on a timestamp. A new worker fences it on a token and a lease. An old worker can therefore complete a row that a new worker owns.
Stop every old worker, apply V6__add_consumption_and_leases.sql and then V7__capture_state.sql, and start the new workers. The existing inbox rows become push rows, which keeps their behaviour. A custom schema must add the new columns and map them.
V11: the key order
Section titled “V11: the key order”V11__add_outbox_sequence.sql adds the outbox sequence column. The new claim delivers the rows of one key in sequence order, one row at a time. The old claim ignores the key, so it can deliver a later row of a key before an earlier one.
Stop every old replica, and apply V11__add_outbox_sequence.sql. The migration numbers the existing rows in created_at order. Then start the new replicas. V11 changes the outbox claim only, so pull workers keep running.
A custom outbox table must add a BIGINT column that the database fills on insert, and map it as database.columnMapping.outbox.sequence. QueueBox stops at startup without it, and it prints the ALTER TABLE statement.
Other migrations that need care
Section titled “Other migrations that need care”- V8, the pull claim indexes.
V8__add_pull_claim_indexes.sqluses a plainCREATE INDEX. On both databases, the build blocks inserts into the inbox until it ends. Plan a maintenance window for a populated inbox. Or build the two indexes online first:CREATE INDEX CONCURRENTLYon PostgreSQL, outside a transaction, orCREATE INDEX ... WITH (ONLINE = ON)on SQL Server Enterprise Edition and Azure SQL. On SQL Server, runSET QUOTED_IDENTIFIER ONfirst, because the indexes are filtered. - V10, the inbox headers.
V10__add_inbox_headers.sqladds the inboxheaderscolumn. A custom inbox table must add it by hand. QueueBox stops at startup without it, and it prints theALTER TABLEstatement. The pull client libraries from 0.3.0 need this column. - V12, the inbox
updated_at.V12__add_updated_at_cursor.sqladds the inboxupdated_atcolumn and fills it for the existing rows. The fill writes every inbox row once, so a large inbox needs a maintenance window, as V8 does. The file also adds an index onupdated_atto both tables. The replicas of the previous version keep running. They do not setupdated_at, so a downstream loader that reads byupdated_atdoes one full reload after the last old replica stops. A custom inbox table must add the column by hand. QueueBox stops at startup without it, and it prints theALTER TABLEstatement. The pull clients Go 0.4.0, TypeScript 0.4.0 and C# 0.6.0 need this column. See Incremental loading. - V13, the pending claim indexes. On PostgreSQL,
V13__separate_pending_claim_indexes.sqladdsidx_inbox_push_pendingand then dropsidx_inbox_consumption_pendingandidx_inbox_pending. The pull claim then has one index for its pending rows. The build of the new index blocks inserts into the inbox until it ends, as V8 does. Plan a maintenance window for a large inbox, or build the index first withCREATE INDEX CONCURRENTLYand the definition from the file. The replicas of the previous version keep running. The file changes nothing on SQL Server. - V14, the autovacuum thresholds. On PostgreSQL,
V14__autovacuum_thresholds.sqlsetsautovacuum_analyze_scale_factor,autovacuum_analyze_threshold,autovacuum_vacuum_scale_factorandautovacuum_vacuum_thresholdoninboxandoutbox. It sets only the keys that the table does not carry, so a value that you set before the upgrade stays. To change a value later, runALTER TABLE ... SETas the table owner. The file changes nothing on SQL Server.
Compatibility policy
Section titled “Compatibility policy”QueueBox keeps these promises for a MINOR release.
For the configuration:
- A MINOR release can add an optional field. The default keeps the previous behaviour.
- A MINOR release can add a value to a field that takes a fixed set of values.
- A MINOR release does not remove, rename or change the meaning of a field.
- A field that QueueBox plans to remove is first marked deprecated in the changelog and in the configuration reference. The removal comes in the next MAJOR release. QueueBox prints no deprecation warning at startup.
For the database schema:
- A MINOR release can add a table, a column or an index. It does not drop a column or change the type of a column.
- Every new column is nullable or has a default.
- An instance of the previous MINOR release runs against the schema of the current MINOR release, except across V6 and V11.
- A destructive change comes only in a MAJOR release. The changelog states the downtime that it needs.
Upgrade the pull clients
Section titled “Upgrade the pull clients”The client libraries release on their own tags, csharp-v*, typescript-v* and clients/go/v*. A client release does not need a QueueBox release. Each client README states the oldest schema that it needs. Upgrade QueueBox and apply the schema before you move a client to a version that needs a newer schema.