XRAY: How to resolve the error "The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 15.2" when upgrading Xray via Helm Chart

XRAY: How to resolve the error "The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 15.2" when upgrading Xray via Helm Chart

AuthorFullName__c
Yunzong Guo
articleNumber
000006312
ft:sourceType
Salesforce
FirstPublishedDate
2025-01-05T12:19:56Z
lastModifiedDate
2025-01-05
VersionNumber
2
Introduction 
 
If you are using the internal PostgreSQL with Xray Helm Chart, you might encounter the following error when upgrading Xray. For example, upgrading the Xray from chart version 103.87.9 to 103.92.7:
$ kubectl logs -f xray-postgresql-0 --namespace xray
postgresql 02:13:02.91 INFO  ==> ** Starting PostgreSQL **
2024-06-26 02:13:02.930 GMT [1] FATAL:  database files are incompatible with server
2024-06-26 02:13:02.930 GMT [1] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 15.2.

From Xray chart 103.91.0, the internal PostgreSQL version is changed from 13.10.0 to 15.2.0.
This issue occurs because PostgreSQL cannot be directly upgraded from version 13 to version 15.


Resolution 

To resolve this, you can upgrade Xray using the PostgreSQL 13 version which is in the previous chart version. After the Xray upgrade is complete, you can later decide whether to upgrade PostgreSQL 13 to PostgreSQL 15.

Step 1:
Modify the Xray's values.yaml file. change the PostgreSQL’s image version to the version that was used in your previous chart (for example, in Xray Chart version 103.87.9, the PostgreSQL tag was 13.10.0-debian-11-r14):
xray:
  joinKey: xxx
  jfrogUrl: http://xxxx
...
postgresql:
  enabled: true
  image:
    registry: releases-docker.jfrog.io
    repository: bitnami/postgresql
    tag: 13.10.0-debian-11-r14
...


Step 2:
Re-run the Xray upgrade command with the updated values.yaml file, for example:
$ helm upgrade --install xray jfrog/xray -f values.yaml --namespace xray

 

Then, the Xray upgrade process will be successful.

You can later decide to migrate/upgrade PostgreSQL from version 13 to version 15 (it is recommended to migrate). For migrating PostgreSQL data from version 13 to 15, you can refer to the following documentation:
https://postgresapp.com/documentation/migrating-data.html


Conclusion 

This article explains how to resolve the issue of upgrading Xray when using the internal PostgreSQL. The error occurs due to the database version change. The solution is to upgrade Xray with the previous PostgreSQL 13 and then optionally migrate or upgrade PostgreSQL from version 13 to 15.