I am following the instructions here to install Oracle foreign data wrapper, oracle_fdw, on a PostgreSQL server.
Oracle version: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production, running on Red Hat Linux 7.2
PostgreSQL version: PostgreSQL 9.4.4 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.7.2-5) 4.7.2, 64-bit, running on Debian 7 (wheezy).
I was able to install sqlplus and connect from PostgreSQL server to Oracle server using sqlplus successfully, so connectivity is not a problem.
But when I try to create the extension, I get the following error:
postgres=# create extension oracle_fdw;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
Then I took clues from https://github.com/dalibo/pg_qualstats/issues/1 and added oracle_fdw to shared_preload_libraries in postgresql.conf like this:
shared_preload_libraries = 'oracle_fdw'
but now I can't restart Postgres:
# service postgresql restart
[....] Restarting PostgreSQL 9.4 database server: main[....] The PostgreSQL server failed to start. Please check the log output: t=2016-09-15 11:05:42 PDT d= h= p=23300 a=FATAL: XX000: invalid cache ID[FAILt=2016-09-15 11:05:42 PDT d= h= p=23300 a=LOCATION: SearchSysCacheList, syscache.c:1219 ... failed!
failed!
Looking into /var/log/postgresql/postgresql-9.4-main.log I only see these two lines:
t=2016-09-15 11:05:42 PDT d= h= p=23300 a=FATAL: XX000: invalid cache ID: 41
t=2016-09-15 11:05:42 PDT d= h= p=23300 a=LOCATION: SearchSysCacheList, syscache.c:1219
Removing oracle_fdw from shared_preload_libraries allows postgres to be restarted, so this is the one causing restart to fail. So I removed oracle_fdw from shared_preload_libraries and kept it just like this in postgresql.conf:
shared_preload_libraries = ''
Then I was able to restart Postgres.
Here are the exact steps done:
# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"
root@app-4:/# cat /etc/debian_version
7.8
root@app-4:/# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.8 (wheezy)
Release: 7.8
Codename: wheezy
Installed using the instructions given here: https://help.ubuntu.com/community/Oracle%20Instant%20Client
I downloaded the following rpm files from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html:
and installed them on the PostgreSQL server using the following commands:
# apt-get install alien
# alien -i oracle-instantclient-basic-10.2.0.3-1.x86_64.rpm
# alien -i oracle-instantclient-devel-10.2.0.3-1.x86_64.rpm
# alien -i oracle-instantclient-sqlplus-10.2.0.3-1.x86_64.rpm
Confirming the installations:
# dpkg --list | grep -i oracle
ii oracle-instantclient-basic 10.2.0.3-2 amd64 Instant Client for Oracle Database 11g
ii oracle-instantclient-devel 10.2.0.3-2 amd64 Development headers for Instant Client.
ii oracle-instantclient-sqlplus 10.2.0.3-2 amd64 SQL*Plus for Instant Client.
# su - postgres
postgres@app-4:~$ sqlplus <ORACLE_USER>/<ORACLE_PASS>@//<ORACLE_HOST>:<ORACLE_PORT>/<SID>
SQL*Plus: Release 10.2.0.3.0 - Production on Fri Sep 16 09:55:02 2016
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select count(*) from <TEST_TABLE>;
COUNT(*)
----------
937530
SQL>
So this works fine.
Downloaded oracle_fdw version 1.4.0 i.e. file oracle_fdw-1.4.0.zip from http://pgxn.org/dist/oracle_fdw/
Then unzipped it and installed it like this:
root@app-4:/home/arun/oracle_fdw-1.4.0# ls
CHANGELOG LICENSE META.json oracle_fdw--1.1.sql oracle_fdw.control oracle_fdw.o oracle_gis.c oracle_utils.c README.oracle_fdw TODO
expected Makefile oracle_fdw--1.0--1.1.sql oracle_fdw.c oracle_fdw.h oracle_fdw.so oracle_gis.o oracle_utils.o sql
root@app-4:/home/arun/oracle_fdw-1.4.0# make
...
root@app-4:/home/arun/oracle_fdw-1.4.0# make install
/bin/mkdir -p '/usr/lib/postgresql/9.4/lib'
/bin/mkdir -p '/usr/share/postgresql/9.4/extension'
/bin/mkdir -p '/usr/share/postgresql/9.4/extension'
/bin/mkdir -p '/usr/share/doc/postgresql-doc-9.4/extension'
/usr/bin/install -c -m 755 oracle_fdw.so '/usr/lib/postgresql/9.4/lib/oracle_fdw.so'
/usr/bin/install -c -m 644 oracle_fdw.control '/usr/share/postgresql/9.4/extension/'
/usr/bin/install -c -m 644 oracle_fdw--1.1.sql oracle_fdw--1.0--1.1.sql '/usr/share/postgresql/9.4/extension/'
/usr/bin/install -c -m 644 README.oracle_fdw '/usr/share/doc/postgresql-doc-9.4/extension/'
root@app-4:/# su - postgres
postgres@app-4:~$ psql
psql (9.4.4)
Type "help" for help.
postgres=# create extension oracle_fdw;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> \q
I installed the GNU debugger (gdb) as recommended by Laurenz Albe in his answer and got the following stack trace (without the debugging symbols for now):
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
#0 0x0000000000000000 in ?? ()
#1 0x00007ff657dfcc99 in DirectFunctionCall1Coll ()
#2 0x00007ff657de19a9 in ?? ()
#3 0x00007ff657de3037 in SearchCatCacheList ()
#4 0x00007ff4c5fcce7d in _PG_init () at oracle_fdw.c:648
#5 0x00007ff657dfb717 in ?? ()
#6 0x00007ff657dfc051 in load_external_function ()
#7 0x00007ff657b6b486 in fmgr_c_validator ()
#8 0x00007ff657dfdeba in OidFunctionCall1Coll ()
#9 0x00007ff657b6aedc in ProcedureCreate ()
#10 0x00007ff657bcf645 in CreateFunction ()
#11 0x00007ff657d14e73 in ?? ()
#12 0x00007ff657d140c7 in standard_ProcessUtility ()
#13 0x00007ff657bc89ed in ?? ()
#14 0x00007ff657bc98de in CreateExtension ()
#15 0x00007ff657d154c1 in ?? ()
#16 0x00007ff657d140c7 in standard_ProcessUtility ()
#17 0x00007ff657d11243 in ?? ()
#18 0x00007ff657d11e96 in ?? ()
#19 0x00007ff657d12b3d in PortalRun ()
#20 0x00007ff657d0fb1a in PostgresMain ()
#21 0x00007ff657acbdad in ?? ()
#22 0x00007ff657caf351 in PostmasterMain ()
#23 0x00007ff657acccba in main ()
Continuing.
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
UPDATE: I was able to install the extension on Postgres 9.4.9 running on debian 8 (8.6, jessie). I used Oracle instant client version 12.1.0.2.0-1 and oracle_fdw version 1.5.
You should really open a Github issue for that, that's the correct place to report an error.
The answer to the following questions will help:
Which version of oracle_fdw
are you using?
What are the exact steps you used to build it? Did you build it on the system where you are running it?
How does the stack trace of the crash look (with debugging symbols)?
Two general remarks:
You should follow the README for building oracle_fdw
and no other web site.
Adding it to shared_preload_libraries
is plain wrong.