gprestore fails with “Cannot load libjvm.so” when restoring PL/Java extension due to missing LD_LIBRARY_PATH in backend processes
search cancel

gprestore fails with “Cannot load libjvm.so” when restoring PL/Java extension due to missing LD_LIBRARY_PATH in backend processes

book

Article ID: 436446

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

When performing a restore using gprestore on a Greenplum cluster that includes the PL/Java extension, the restore operation may fail with the following error:

ERROR: Cannot load libjvm.so library, check that it is available in LD_LIBRARY_PATH (SQLSTATE XX000)

 

This error typically occurs during the metadata restore phase when gprestore attempts to execute:

CREATE EXTENSION pljava;
 

Although the libjvm.so library may exist on all hosts and the LD_LIBRARY_PATH environment variable may be correctly set in user shell configuration files (e.g., .bashrc), the issue may persist.

Cause

Greenplum backend processes (master and segment instances) do not source user-level shell configuration files such as .bashrc. As a result, any updates made to LD_LIBRARY_PATH in these files are not visible to the database processes.

Due to this, the backend processes are unable to locate the required libjvm.so library during the execution of PL/Java-related commands, leading to the restore failure.

Additionally, inconsistent LD_LIBRARY_PATH values across cluster nodes (master, standby, segments) can further contribute to the issue.

Resolution

Ensure that the required Java library paths are configured at the Greenplum environment level and are consistently applied across all nodes.

You can follow below steps:

  1. Update the Greenplum environment configuration file:

    Edit the following file on all hosts (master, standby, and segment nodes):

    $GPHOME/greenplum_path.sh
     
  2. Add or update the following environment variables:

    export JAVA_HOME=/usr/lib/jvm/jre
    export LD_LIBRARY_PATH=$JAVA_HOME/lib/amd64/server:$LD_LIBRARY_PATH
     
     
  3. Ensure that the path to libjvm.so is correct and identical across all nodes in the cluster.
  4. Apply the changes and restart Greenplum:

    source $GPHOME/greenplum_path.sh
    gpstop -r
     
  5. Validate consistency across all hosts:

    gpssh -f all_hosts_file 'echo $LD_LIBRARY_PATH'
     
     
  6. Re-run the gprestore operation.