EnterpriseDB / mongo_fdw

PostgreSQL foreign data wrapper for MongoDB
GNU Lesser General Public License v3.0
326 stars 70 forks source link

postgres crashed #136

Closed kos12345 closed 4 years ago

kos12345 commented 4 years ago

OS: ubuntu 18.04 Postgres 11.8 Mongo 4.2.3

install mongo-c-driver: apt-get install libmongoc-1.0-0 apt-get install libbson-1.0 sudo apt-get install cmake libssl-dev libsasl2-dev

wget https://github.com/mongodb/mongo-c-driver/releases/download/1.16.2/mongo-c-driver-1.16.2.tar.gz tar xzf mongo-c-driver-1.16.2.tar.gz cd mongo-c-driver-1.16.2 mkdir cmake-build cd cmake-build cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF .. sudo make install

install mongo_fdw: git clone --recursive https://github.com/EnterpriseDB/mongo_fdw cd mongo_fdw/ ./autogen.sh --with-legacy (also try ./autogen.sh --with-master) make -f Makefile.meta && make -f Makefile.meta install

PSQL:

CREATE EXTENSION mongo_fdw; CREATE SERVER mongo_server FOREIGN DATA WRAPPER mongo_fdw OPTIONS (address '127.0.0.1', port '27017',authentication_database 'admin'); CREATE USER MAPPING FOR postgres SERVER mongo_server OPTIONS (username 'read', password 'read1'); CREATE FOREIGN TABLE data(_id NAME ,data text) SERVER mongo_server OPTIONS (database 'pg_test', collection 'data');

TRY SELECT * FROM data; AND result- postgres server crashed

postgres=# SELECT * FROM data; 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.

what I do wrong?

vaibhavdalvi93 commented 4 years ago

I went through steps you have mentioned above and below are my observations:

  1. I am not sure whether you have compiled mongo_fdw source against mongoc driver version 1.9.5 (mentioned in autogen.sh) or mongoc driver version 1.16.2?. You have installed mongo-c-driver 1.16.2 using "wget" and later ran autogen.sh which will also download and build mongo-c-driver version 1.9.5.
  2. Please note that if you are using autogen.sh then there is no need to separately install mongo-c-driver. You can skip below two steps you have performed:

    1. install mongo-c-driver: apt-get install libmongoc-1.0-0 apt-get install libbson-1.0 sudo apt-get install cmake libssl-dev libsasl2-dev

    2. wget https://github.com/mongodb/mongo-c-driver/releases/download/1.16.2/mongo-c-driver-1.16.2.tar.gz tar xzf mongo-c-driver-1.16.2.tar.gz cd mongo-c-driver-1.16.2 mkdir cmake-build cd cmake-build cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF .. sudo make install

You can perform following 3 steps: 1. Simply run autogen.sh, which will do all the necessary steps to build with legacy and meta-driver accordingly(Refer https://github.com/EnterpriseDB/mongo_fdw#compilation-script). 2. Compile mongo_fdw code against installed mongo-c-driver in the first step. 3. CREATE EXTENSION mongo_fdw; CREATE SERVER mongo_server FOREIGN DATA WRAPPER mongo_fdw OPTIONS (address '127.0.0.1', port '27017',authentication_database 'admin'); CREATE USER MAPPING FOR postgres SERVER mongo_server OPTIONS (username 'read', password 'read1'); CREATE FOREIGN TABLE data(_id NAME ,data text) SERVER mongo_server OPTIONS (database 'pg_test', collection 'data');

Kindly let us know if postgres is still getting crashed and attach backtrace so that will look into it in detail.

kos12345 commented 4 years ago

i uninstall: libmongoc-1.0-0 libbson-1.0 mongo-c-driver-1.16.2

and reinstall: git clone --recursive https://github.com/EnterpriseDB/mongo_fdw cd mongo_fdw/ ./autogen.sh --with-master make -f Makefile.meta && make -f Makefile.meta install

and it's works! thank you!