Problem
The Terraform Enterprise (TFE) application version must be compatible with the schema version of its PostgreSQL database. If these versions are mismatched, TFE may fail to start, presenting various errors.
Common scenarios include:
- TFE version is lower than the database schema version: TFE will fail to start.
- TFE version is higher than the database schema version: TFE will attempt to upgrade the database schema. This may succeed, or it may fail if a mandatory intermediate release was skipped during an upgrade.
Example error messages in the application status may include Container ptfe_registry_migrations failed, context deadline exceeded, or Timeout waiting for event nginx started.
## Example error 1
$ replicatedctl app status
[ { "AppID": "15d424fba1e64bf47618f01b764e765d", "State": "stopped", "Error": "Container ptfe_registry_migrations failed: Container ... exited with non-zero exit status 1: "... }]
## Example error 2
$ replicatedctl app status
[ { "AppID": "ff26b23cbe3042f852c5ec5ab0ee27d2", "State": "started", "Error": "Ready state command canceled: context deadline exceeded", ... }]
## Example error 3
$ replicatedctl app status
[ { "AppID": "837ee5c406334c744b60eb3086f09573", "State": "stopped", "Error": "Container tfe-nginx failed: Timeout waiting for event nginx started-80", ... }]To troubleshoot these issues, you must first verify the current schema version stored in the PostgreSQL database.
Solutions
This guide provides several methods to check the PostgreSQL schema version for both Replicated and Flexible Deployment Options (FDO) installations.
Solution 1: Verify Schema on Replicated Deployments
You can use one of the following methods depending on your environment's status and your access level.
Method A: Use the tfe-atlas container
Execute the db:version Rake task inside the tfe-atlas container.
$ docker exec -it tfe-atlas /usr/bin/init.sh /app/scripts/wait-for-token -- \ bash -i -c 'cd /app && ./bin/rake db:version'
The command returns the current schema version.
Current version: 20230206193105
Method B: Query PostgreSQL directly
-
Log in to the TFE PostgreSQL environment.
$ sudo docker exec -ti tfe-atlas /bin/bash # psql -h <fqdn> -p 5432 -U <username>
-
Connect to your TFE database. In this example, the database is named
tfe.postgres=> \c tfe
-
Run the following query to retrieve the latest schema version.
tfe=> SELECT * FROM rails.schema_migrations ORDER BY version DESC LIMIT 1;
The command returns the version.
version ---------------- 20230206193105
Method C: Check logs in a support bundle
After generating a support bundle, inspect the ptfe_migrations.stdout or tfe-migrations.stdout log file for an entry indicating the schema version.
## File: primary/app/logs/ptfe_migrations.stdout Current version: 20230206193105
Solution 2: Verify Schema on Flexible Deployment Options (FDO)
-
Log in to the Rails console using
tfectl.$ tfectl support console
- From the console, run the following commands to get the database, application schema, and private registry schema versions.
-
Database Version
ActiveRecord::Base.connection.execute("SELECT version();").first["version"] -
TFE Application Schema Version
ActiveRecord::Base.connection.execute("SELECT * FROM rails.schema_migrations ORDER BY version DESC LIMIT 1").first["version"] -
TFE Private Registry Schema Version
result = ActiveRecord::Base.connection.execute("SELECT * FROM registry.schema_migrations;").first version = result["version"] dirty = result["dirty"] puts "Version: #{version}, Dirty: #{dirty}"
-
TFE Version to Schema Version Mapping
Use the following table to correlate your TFE release version with its corresponding PostgreSQL schema versions.
| TFE Version | Sequence | PostgreSQL ATLAS Schema | PostgreSQL REGISTRY Schema |
|---|---|---|---|
| v202504-1 | n/a | 20250403151234 | 124 |
| v202503-1 | 811 | 20250304033840 | 124 |
| v202502-2 | 810 | 20250204165148 | 124 |
| v202502-1 | 808 | 20250204165148 | 124 |
| v202501-1 | 806 | 20241219170344 | 124 |
| v202411-2 | 805 | 20241114171357 | 124 |
| v202411-1 | 804 | 20241114171357 | 124 |
| v202410-1 | 798 | 20241003172501 | 124 |
| v202409-3 | 791 | 20240829151432 | 124 |
| v202409-2 | 789 | 20240829151432 | 124 |
| v202409-1 | 787 | 20240829151432 | 124 |
| v202408-1 | 781 | 20240802100755 | 121 |
| v202407-1 | 779 | 20240702133822 | 120 |
| v202406-1 | 776 | 20240605220527 | 120 |
| v202405-1 | 772 | 20240430153813 | 120 |
| v202404-2 | 764 | 20240411005806 | 119 |
| v202402-2 | 760 | 20240228165331 | 114 |
| v202402-1 | 759 | 20240228165331 | 114 |
| v202401-2 | 757 | 20240119145909 | 112 |
| v202312-1 | 745 | 20231119211536 | 103 |
| v202311-1 | 742 | 20231019025905 | 103 |
| v202310-1 | 741 | 20230920111900 | 99 |
| v202309-1 | 733 | 20230821094814 | 99 |
| v202308-1 | 725 | 20230725220632 | 99 |
| v202307-1 | 722 | 20230628000004 | 98 |
| v202306-1 | 713 | 20230602155756 | 98 |
| v202305-2 | 706 | 20230505210617 | 97 |
| v202305-1 | 703 | 20230505210617 | 97 |
| v202304-1 | 692 | 20230405115900 | 94 |
| v202303-1 | 688 | 20230301111746 | 94 |
| v202302-1 | 681 | 20230206193105 | 91 |
| v202301-2 | 676 | 20230111175717 | 89 |
| v202301-1 | 675 | 20230111175717 | 89 |
| v202212-2 | 667 | 20221111173907 | 81 |
| v202212-1 | 665 | 20221111173907 | 81 |
| v202211-1 | 660 | 20221018165153 | 81 |
| v202210-1 | 659 | 20220920202716 | 81 |
| v202209-2 | 655 | 20220824171618 | 81 |
| v202209-1 | 654 | 20220824171618 | 81 |
| v202208-3 | 652 | 20220725034301 | 79 |
| v202208-2 | 651 | 20220725034301 | 79 |
| v202208-1 | 647 | 20220725034301 | 79 |
| v202207-2* | 642 | 20220629165800 | 75 |
| v202207-1 | 641 | 20220629165800 | 75 |
| v202206-1 | 636 | 20220531194545 | 66 |
| v202205-1 | 619 | 20220427172606 | 64 |
| v202204-2* | 610 | 20220406113100 | 57 |
| v202204-1 | 609 | 20220406113100 | 57 |
| v202203-1 | 607 | 20220302233223 | 55 |
| v202202-1 | 599 | 20220204212407 | 54 |
| v202201-2 | 595 | 20220118213313 | 53 |
| v202201-1 | 594 | 20220118213313 | 53 |
Additional Information
For a complete list of versions and required upgrade paths, refer to the Terraform Enterprise release notes.