As with any other software there comes the time when you need to patch your Postgres Plus Advanced Server instances. Is that different from patching Community PostgreSQL? Yes and no 🙂 The difference is that you need a subscription to get access to the EDB Customer Portal for being able to download the patch. This is pretty much the same as with My Oracle Support where you need a customer support identifier mapped to your account for being able to download patches, to have access to the knowledge base and for being able to open cases in case you run into troubles which you are not able to solve yourself.

Assuming you have access to the EDB customer portal and you downloaded the patch for your base release the procedure is pretty simple. For this little demo I am running the 9.5.0.5 base release of Postgres Plus Advanced Server:

postgres@centos7:/home/postgres/ [PG2] psql
psql.bin (9.5.0.5)
Type "help" for help.

postgres=# select version();
                                                   version                                                    
--------------------------------------------------------------------------------------------------------------
 EnterpriseDB 9.5.0.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55), 64-bit
(1 row)

postgres=# 

This is the release you can download from the EDB website for testing. The patch I downloaded from the portal is this one:

postgres@centos7:/home/postgres/ [PG2] cd /u01/app/postgres/software/
postgres@centos7:/u01/app/postgres/software/ [PG2] ls -la
total 27216
drwxrwxr-x. 2 postgres postgres       51 Oct  5 10:16 .
drwxrwxr-x. 5 postgres postgres       47 Jun 15 13:10 ..
-rw-rw-r--. 1 postgres postgres 27868299 Oct  5 10:16 postgresplusas-9.5.4.9-1-linux-x64.run
postgres@centos7:/u01/app/postgres/software/ [PG2] chmod +x postgresplusas-9.5.4.9-1-linux-x64.run 

This should patch my base release to currently latest release which is 9.5.4.9-1. How does it work? Lets execute the binary and see what happens:

postgres@centos7:/u01/app/postgres/software/ [PG2] ./postgresplusas-9.5.4.9-1-linux-x64.run 
Language Selection

Please select the installation language
[1] English - English
[2] Japanese - 日本語
[3] Simplified Chinese - 简体中文
[4] Traditional Chinese - 繁体中文
[5] Korean - 한국어
Please choose an option [1] : 1

Error: There has been an error.
This installer requires root privileges. Please become superuser before 
executing the installer
Press [Enter] to continue:

A no go for most of the cases. Running installers as root is not a good practice and should be avoided whenever possible. But, luckily, as with the base release installer the patch itself can be installed in “extract only” mode:

postgres@centos7:/u01/app/postgres/software/ [PG2] ./postgresplusas-9.5.4.9-1-linux-x64.run --extract-only yes --prefix /u01/app/postgres/product/95edb/db_5/9.5AS/
Language Selection

Please select the installation language
[1] English - English
[2] Japanese - 日本語
[3] Simplified Chinese - 简体中文
[4] Traditional Chinese - 繁体中文
[5] Korean - 한국어
Please choose an option [1] : 1
----------------------------------------------------------------------------
Welcome to the Postgres Plus Advanced Server Setup Wizard.

----------------------------------------------------------------------------
Please specify the directory where Postgres Plus Advanced Server will be 
installed.

Installation Directory [/u01/app/postgres/product/95edb/db_5/9.5AS]: 

----------------------------------------------------------------------------
Setup is now ready to begin installing Postgres Plus Advanced Server on your 
computer.

Do you want to continue? [Y/n]: y

----------------------------------------------------------------------------
Please wait while Setup installs Postgres Plus Advanced Server on your computer.

 Installing Database Server
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing Postgres Plus Advanced Server on your computer.

postgres@centos7:/u01/app/postgres/software/ [PG2] 

Looks good, but you never should do this when your PostgreSQL is running, otherwise you’ll get this:

2016-10-05 10:22:43 CEST LOG:  server process (PID 4359) was terminated by signal 11: Segmentation fault
2016-10-05 10:22:43 CEST LOG:  terminating any other active server processes
2016-10-05 10:22:43 CEST WARNING:  terminating connection because of crash of another server process
2016-10-05 10:22:43 CEST DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2016-10-05 10:22:43 CEST HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2016-10-05 10:22:43 CEST LOG:  statistics collector process (PID 3324) was terminated by signal 11: Segmentation fault
2016-10-05 10:22:43 CEST LOG:  all server processes terminated; reinitializing

Always shutdown, before you begin to patch. In my case I just started the instance again and I am on the current release:

postgres@centos7:/u01/app/postgres/software/ [PG2] sqh
psql.bin (9.5.4.9)
Type "help" for help.

postgres=# select version();
                                                   version                                                    
--------------------------------------------------------------------------------------------------------------
 EnterpriseDB 9.5.4.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55), 64-bit
(1 row)

postgres=# 

Simple and fast. If you prepare this very well your downtime will be around one minute. I can already hear the question: Can I switchover to my standby, apply the patch on the master, switchback and then proceed on the standby for reducing the downtime even more? This will be a topic for another post.

PS: Of course you can also prepare a brand new home for the patched binaries and then shutdown your instance, switch to the new binaries and start again from there.

PS2: Just in case you are not aware of: As we have established a partnership with EnterpriseDB in the past you can obtain (an) EDB subscription(s) easily from us. Of course we would do a review of what you really need before. It is not always required to go for the Postgres Plus version. Community PostgreSQL works very well in the most cases and can be backed by a EDB subscription as well, if required.