laurenz / oracle_fdw

PostgreSQL Foreign Data Wrapper for Oracle
http://laurenz.github.io/oracle_fdw/
Other
496 stars 156 forks source link

Unable to load libclntsh.so.21.1 #689

Closed kikijolicoeur closed 4 months ago

kikijolicoeur commented 4 months ago

Hello. I use PostgreSQL 14 (but I have the same result with version 16) on Debian 11. I installed PostgreSQL from a mirror of apt.postgresql.org. apt-get install postgresql-14-oracle-fdw runs without problem and download oracle libraries : download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip and download.oracle.com/otn_software/linux/instantclient/instantclient-sdk-linuxx64.zip. These libraries are installed in /usr/lib/oracle but with the version 23.1. There are symbolic links for version 21.1 that points on 23.1. I saw in post-install that ldconfig is performed (with the file /etc/ld.so.conf.d/oracle-libs.conf that contains the line: /usr/lib/oracle When I try to create extension I have the following message :

[local]:5432 postgres@croux=# create extension oracle_fdw; ERROR: could not load library "/usr/lib/postgresql/16/lib/oracle_fdw.so": libclntsh.so.21.1: cannot open shared object file: No such file or directory [local]:5432 postgres@croux=#

In the issue 64 (https://github.com/laurenz/oracle_fdw/issues/64) you said :" using ldconfig is much better" but ldconfig ignores the symbolic links, so when I run ldconfig --print I only see the following:

root@rebpgqh301:/etc# ldconfig --print|grep oracle libtfojdbc1.so (libc6,x86-64) => /usr/lib/oracle/libtfojdbc1.so libocijdbc23.so (libc6,x86-64) => /usr/lib/oracle/libocijdbc23.so libociicus.so (libc6,x86-64) => /usr/lib/oracle/libociicus.so libocci.so.23.1 (libc6,x86-64) => /usr/lib/oracle/libocci.so.23.1 libocci.so (libc6,x86-64) => /usr/lib/oracle/libocci.so libnnz.so (libc6,x86-64) => /usr/lib/oracle/libnnz.so libclntshcore.so.23.1 (libc6,x86-64) => /usr/lib/oracle/libclntshcore.so.23.1 libclntshcore.so (libc6,x86-64) => /usr/lib/oracle/libclntshcore.so libclntsh.so.23.1 (libc6,x86-64) => /usr/lib/oracle/libclntsh.so.23.1 libclntsh.so (libc6,x86-64) => /usr/lib/oracle/libclntsh.so

The only way I found to create extension successfully was to create symbolic links in /lib/x86_64-linux-gnu as following: root@rebpgcrom5h01:/lib/x86_64-linux-gnu# ll libcln* lrwxrwxrwx 1 root root 37 Jul 9 14:50 libclntshcore.so.21.1 -> /usr/lib/oracle/libclntshcore.so.21.1 lrwxrwxrwx 1 root root 33 Jul 9 14:50 libclntsh.so.21.1 -> /usr/lib/oracle/libclntsh.so.21.1 root@rebpgcrom5h01:/lib/x86_64-linux-gnu#

In my case I start PostgreSQL with Systemd or Patroni My question: why do you link oracle_fdw to a specific version (21.1) ?

root@rebpgcrom5h01:~# objdump -p /usr/lib/postgresql/14/lib/oracle_fdw.so|grep NEEDED NEEDED libclntsh.so.21.1 NEEDED libc.so.6

What do you think about link to libclntsh.so ? When oracle librarries are installed we have : root@rebpgcrom5h01:~# ll /usr/lib/oracle total 129892 -rwxr-xr-x 1 root root 2124576 Apr 24 15:38 fips.so -rwxr-xr-x 1 root root 5463312 Apr 24 15:38 legacy.so lrwxrwxrwx 1 root root 21 Jul 9 09:16 libclntshcore.so -> libclntshcore.so.23.1 lrwxrwxrwx 1 root root 21 Jul 9 09:16 libclntshcore.so.12.1 -> libclntshcore.so.23.1 lrwxrwxrwx 1 root root 21 Jul 9 09:16 libclntshcore.so.18.1 -> libclntshcore.so.23.1 lrwxrwxrwx 1 root root 21 Jul 9 09:16 libclntshcore.so.19.1 -> libclntshcore.so.23.1 lrwxrwxrwx 1 root root 21 Jul 9 09:16 libclntshcore.so.20.1 -> libclntshcore.so.23.1 lrwxrwxrwx 1 root root 21 Jul 9 09:16 libclntshcore.so.21.1 -> libclntshcore.so.23.1 lrwxrwxrwx 1 root root 21 Jul 9 09:16 libclntshcore.so.22.1 -> libclntshcore.so.23.1 -rwxr-xr-x 1 root root 4562064 Apr 24 15:38 libclntshcore.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so -> libclntsh.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so.10.1 -> libclntsh.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so.11.1 -> libclntsh.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so.12.1 -> libclntsh.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so.18.1 -> libclntsh.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so.19.1 -> libclntsh.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so.20.1 -> libclntsh.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so.21.1 -> libclntsh.so.23.1 lrwxrwxrwx 1 root root 17 Jul 9 09:16 libclntsh.so.22.1 -> libclntsh.so.23.1 -rwxr-xr-x 1 root root 94620096 Apr 24 15:31 libclntsh.so.23.1 -rwxr-xr-x 1 root root 8460728 Apr 15 08:04 libnnz.so lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so -> libocci.so.23.1 lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so.10.1 -> libocci.so.23.1 lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so.11.1 -> libocci.so.23.1 lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so.12.1 -> libocci.so.23.1 lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so.18.1 -> libocci.so.23.1 lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so.19.1 -> libocci.so.23.1 lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so.20.1 -> libocci.so.23.1 lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so.21.1 -> libocci.so.23.1 lrwxrwxrwx 1 root root 15 Jul 9 09:16 libocci.so.22.1 -> libocci.so.23.1 -rwxr-xr-x 1 root root 1321216 Apr 24 15:38 libocci.so.23.1 -rwxr-xr-x 1 root root 10760680 Apr 24 15:38 libociicus.so -r-xr-xr-x 1 root root 164328 Apr 24 15:38 libocijdbc23.so -r-xr-xr-x 1 root root 19016 Apr 24 15:38 libtfojdbc1.so -rwxr-xr-x 1 root root 5493184 Apr 24 15:38 pkcs11.so root@rebpgcrom5h01:~#

so libraries 21.1 are compatible with version 23.1 and libclntsh.so is in ld cache. So It should work without create symbolic link.

Thank you for developing oracle_fdw

Best regards

Christian

laurenz commented 4 months ago

I can confirm that Linux ignores symbolic links in directories configured with ldconfig.

I guess you will have to set the LD_LIBRARY_PATH environment variable to the Oracle Instant Client directory in the environment of the PostgreSQL server. That should work, and I cannot think of a better way.

I don't feel responsible for the binary packages, but I agree that is undesirable that oracle_fdw won't work without additional configuration if you want to use a different Oracle client version than the one with which it was built.

kikijolicoeur commented 4 months ago

Unfortunately, the 21.1 version is no more downloadable from Oracle web site. Thanks for you answer

laurenz commented 4 months ago

I'm curious: did you get it to work with LD_LIBRARY_PATH?