0

I recently upgraded PostgreSQL from v12.14 to v15.2. During the upgrade, I also had to update the pg_repack extension from v1.4.5 to v1.4.8. However, when I attempted to run pg_repack, I encountered the error: "pg_repack failed with error: program 'pg_repack 1.4.5' does not match database library 'pg_repack 1.4.8'".

I followed the steps outlined in this document, but it's not as straightforward as it's described here. https://reorg.github.io/pg_repack/#installation

1 Answers1

0

At last, I discovered a solution to resolve this problem. Note: The steps below were executed on an Ubuntu system (v22.04) without any previous installation.

sudo apt-get update 
sudo apt-get install postgresql-server-dev-all
    
sudo apt-get install postgresql-common 
sudo apt-get install pgxnclient
sudo apt install gcc
sudo su
export PATH=/usr/lib/postgresql/14/bin:$PATH
sudo apt-get install liblz4-dev
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
sudo apt-get install libreadline-dev
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
sudo apt-get install zlib1g-dev
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
pgxn install pg_repack

# Now you are ready to run pg_repack using following command
pg_repack -h <HOST-NAME> -p <PORT NUMBER> -d <DATABASE NAME> -U <USERNAME> -k

Note:

Edit the .bashrc file to include the following environment variable.

export PATH=/usr/lib/postgresql/14/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Refer to this blog to learn more about pg_repack and its available parameters.