Upgrading Citus Versions¶
Citus adheres to semantic versioning with patch-, minor-, and major-versions. The upgrade process differs for each, requiring more effort for bigger version jumps.
Upgrading the Citus version requires first obtaining the new Citus extension and then installing it in each of your database instances. Citus uses separate packages for each minor version to ensure that running a default package upgrade will provide bug fixes but never break anything. Let’s start by examining patch upgrades, the easiest kind.
Patch Version Upgrade¶
To upgrade a Citus version to its latest patch, issue a standard upgrade command for your package manager. Assuming version 10.0 is currently installed on Postgres 13:
Ubuntu or Debian
sudo apt-get update sudo apt-get install --only-upgrade postgresql-13-citus-10.0 sudo service postgresql restart
Fedora, CentOS, or Red Hat
sudo yum update citus100_13 sudo service postgresql-13 restart
Major and Minor Version Upgrades¶
Major and minor version upgrades follow the same steps, but be careful: major upgrades can make backward-incompatible changes in the Citus API. It is best to review the Citus changelog before a major upgrade and look for any changes which may cause problems for your application.
Starting at version 8.1, new Citus nodes expect and require encrypted inter-node communication by default, whereas nodes upgraded to 8.1 from an earlier version preserve their earlier SSL settings. Be careful when adding a new Citus 8.1 (or newer) node to an upgraded cluster that does not yet use SSL. The adding a worker section covers that situation.
Each major and minor version of Citus is published as a package with a separate name. Installing a newer package will automatically remove the older version.
Step 1. Update Citus Package¶
If upgrading both Citus and Postgres, always be sure to upgrade the Citus extension first, and the PostgreSQL version second (see Upgrading PostgreSQL version from 12 to 13). Here is how to do a Citus upgrade from 9.5 to 10.0
Ubuntu or Debian
sudo apt-get update sudo apt-get install postgresql-12-citus-10.0 sudo service postgresql restart
Fedora, CentOS, or Red Hat
# Fedora, CentOS, or Red Hat sudo yum swap citus95_12 citus100_12 sudo service postgresql-12 restart
Step 2. Apply Update in DB¶
After installing the new package and restarting the database, run the extension upgrade script.
# you must restart PostgreSQL before running this psql -c 'ALTER EXTENSION citus UPDATE;' # you should see the newer Citus version in the list psql -c '\dx'
During a major version upgrade, from the moment of yum installing a new version, Citus will refuse to run distributed queries until the server is restarted and ALTER EXTENSION is executed. This is to protect your data, as Citus object and function definitions are specific to a version. After a yum install you should (a) restart and (b) run alter extension. In rare cases if you experience an error with upgrades, you can disable this check via the citus.enable_version_checks configuration parameter. You can also contact us providing information about the error, so we can help debug the issue.
Upgrading PostgreSQL version from 12 to 13¶
Do not attempt to upgrade both Citus and Postgres versions at once. If both upgrades are desired, upgrade Citus first.
Record the following paths before you start (your actual paths may be different than those below):
- Existing data directory (e.g. /opt/pgsql/10/data)
- Existing PostgreSQL installation path (e.g. /usr/pgsql-10)
- New data directory after upgrade
- New PostgreSQL installation path
For Every Node¶
- Back up Citus metadata in the old coordinator node.
-- this step for the coordinator node only, not workers SELECT citus_prepare_pg_upgrade();
- Configure the new database instance to use Citus.
Include Citus as a shared preload library in postgresql.conf:shared_preload_libraries = 'citus'
DO NOT CREATE Citus extension
DO NOT start the new server
Stop the old server.
Check upgrade compatibility.
$NEW_PG_PATH/bin/pg_upgrade -b $OLD_PG_PATH/bin/ -B $NEW_PG_PATH/bin/ \ -d $OLD_PG_DATA -D $NEW_PG_DATA --check
You should see a “Clusters are compatible” message. If you do not, fix any errors before proceeding. Please ensure that
NEW_PG_DATAcontains an empty database initialized by new PostgreSQL version
- The Citus extension IS NOT created
- Perform the upgrade (like before but without the
$NEW_PG_PATH/bin/pg_upgrade -b $OLD_PG_PATH/bin/ -B $NEW_PG_PATH/bin/ \ -d $OLD_PG_DATA -D $NEW_PG_DATA
- Start the new server.
- DO NOT run any query before running the queries given in the next step
- Restore metadata on new coordinator node.
-- this step for the coordinator node only, not workers SELECT citus_finish_pg_upgrade();