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.
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.
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:
Update the Greenplum environment configuration file:
Edit the following file on all hosts (master, standby, and segment nodes):
$GPHOME/greenplum_path.shAdd or update the following environment variables:
export JAVA_HOME=/usr/lib/jvm/jreexport LD_LIBRARY_PATH=$JAVA_HOME/lib/amd64/server:$LD_LIBRARY_PATHlibjvm.so is correct and identical across all nodes in the cluster.Apply the changes and restart Greenplum:
source $GPHOME/greenplum_path.shgpstop -rValidate consistency across all hosts:
gpssh -f all_hosts_file 'echo $LD_LIBRARY_PATH'gprestore operation.