How to perform a major version downgrade Platform Extension Framework in Tanzu Greenplum
search cancel

How to perform a major version downgrade Platform Extension Framework in Tanzu Greenplum

book

Article ID: 296694

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

After performing a major upgrade of Platform Extension Framework (PXF) from PXF 5.x to PXF 6.x, there may be times where you are forced to downgrade back to 5.x or you simply need a back out plan.

This article explains how to perform the downgrade in cases where the extension is not able to be dropped due to dependent objects.

Note: Make sure to take backup of PXF directories before proceeding.

If you are trying to perform a minor version downgrade of PFX, refer to How to perform a minor version downgrade of Platform Extension Framework 6.x in Tanzu Greenplum.

Environment

Product Version: 6.16

Resolution

Downgrade from PXF 6.x to PXF 5.14+


1. Shut down PXF services using this command:

pxf cluster stop


2. Make sure PXF_CONF environment variable is still referencing the old PXF location.

3. As root, install the PXF software for the version you are looking to downgrade to on all hosts: 

rpm -Uvh --oldpackage [downloaded_lower_version_package]


4. Initialize PXF using this command:

pxf cluster init
 

5. Since this is a major downgrade, some changes need to be reverted for the PXF extension. 

The following functions need to be run in the database where the PXF extension is located.

Note: This only needs to be done if you want to retain the current objects which are dependent on PXF, otherwise you can recreate the extension.

CREATE OR REPLACE FUNCTION pg_catalog.pxf_write() RETURNS integer
AS '$libdir/pxf.so', 'pxfprotocol_export'
LANGUAGE C STABLE;

CREATE OR REPLACE FUNCTION pg_catalog.pxf_read() RETURNS integer
AS '$libdir/pxf.so', 'pxfprotocol_import'
LANGUAGE C STABLE;

CREATE OR REPLACE FUNCTION pg_catalog.pxf_validate() RETURNS void
AS '$libdir/pxf.so', 'pxfprotocol_validate_urls'
LANGUAGE C STABLE;

CREATE OR REPLACE FUNCTION pg_catalog.pxfwritable_import() RETURNS record
AS '$libdir/pxf.so', 'gpdbwritableformatter_import'
LANGUAGE C STABLE;

CREATE OR REPLACE FUNCTION pg_catalog.pxfwritable_export(record) RETURNS bytea
AS '$libdir/pxf.so', 'gpdbwritableformatter_export'
LANGUAGE C STABLE;
 

6. Start PXF with this command:

pxf cluster start
 

Upgrade PXF 5.14+ to PXF 6.x after downgrade

Note: The follow steps only apply if you performed the downgrade procedure from above. If you are doing a fresh upgrade or you are able to drop the PXF extension, refer to Upgrading from PXF 5.x.

1. If PXF is not already installed, install PXF 6.x on all hosts as root:

rpm -Uvh --oldpackage [downloaded_lower_version_package]
2. Perform the migration from PXF 5.x to PXF 6.x:
PXF_CONF=/path/to/dir pxf cluster migrate
Where PXF_CONF is the location of PXF 5.x.


3. Run this command:

pxf cluster register


4. Normally we would update the extension. However this will not work in this case because the extension already thinks it's been upgraded.

Instead we'll need to do the following:

a. Locate the file, /usr/local/pxf-gp6/gpextable/pxf.control.

b. In this file, locate module_pathname and note it down.

c. Run the following functions and replace MODULE_PATHNAME with the value from the previous step:

CREATE OR REPLACE FUNCTION pg_catalog.pxf_write() RETURNS integer
AS 'MODULE_PATHNAME', 'pxfprotocol_export'
LANGUAGE C STABLE;

CREATE OR REPLACE FUNCTION pg_catalog.pxf_read() RETURNS integer
AS 'MODULE_PATHNAME', 'pxfprotocol_import'
LANGUAGE C STABLE;

CREATE OR REPLACE FUNCTION pg_catalog.pxf_validate() RETURNS void
AS 'MODULE_PATHNAME', 'pxfprotocol_validate_urls'
LANGUAGE C STABLE;

CREATE OR REPLACE FUNCTION pg_catalog.pxfwritable_import() RETURNS record
AS 'MODULE_PATHNAME', 'gpdbwritableformatter_import'
LANGUAGE C STABLE;

CREATE OR REPLACE FUNCTION pg_catalog.pxfwritable_export(record) RETURNS bytea
AS 'MODULE_PATHNAME', 'gpdbwritableformatter_export'
LANGUAGE C STABLE;
 

5. Run this command:

pxf cluster sync
 

6. Run this command: 

pxf cluster start