EnterpriseDB / mongo_fdw

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

Support for mongo 3.6 #104

Closed freshfx closed 2 years ago

freshfx commented 6 years ago

I'm running mongo and postgres in different docker container.

#start mongo
docker run --rm --name mongo -e "MONGO_INITDB_ROOT_USERNAME=root" -e "MONGO_INITDB_ROOT_PASSWORD=example" -d mongo

I created a users collection in the test database and inserted one document.

# start postgres
docker run -it --rm --name postgres --link mongo:mongo -d postgres bash

# connect to postgres
docker exec -it postgres bash

# install mongo_fdw
root@6626158a6505:/# git clone --recursive https://github.com/EnterpriseDB/mongo_fdw.git root@6626158a6505:/# /tmp/fdw
root@6626158a6505:/# cd /tmp/fdw && ./autogen.sh --with-master
root@6626158a6505:/# ldconfig
root@6626158a6505:/# cd /tmp/fdw && make clean && make && make install

# run postgres (in background)
root@6626158a6505:/# /docker-entrypoint.sh postgres &

To create the foreign tables i run following codes:

# start psql terminal
root@6626158a6505:/# psql -U postgres

# connect to mongo and create foreign table
postgres=# CREATE EXTENSION mongo_fdw;
postgres=# CREATE SERVER mongo1 FOREIGN DATA WRAPPER mongo_fdw OPTIONS (address '172.17.0.2', port '27017', authentication_database 'admin');
postgres=# CREATE USER MAPPING FOR postgres SERVER mongo1 OPTIONS (username 'root', password 'example');
postgres=# CREATE FOREIGN TABLE IF NOT EXISTS users(
  "_id" NAME
) SERVER mongo1
  OPTIONS (database 'test', collection 'users');

Every time I try so query a select i get the following error:

postgres=# SELECT * FROM users;
*** Error in `postgres: postgres postgres [local] SELECT': double free or corruption (fasttop): 0x000055bc05b5f930 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bfb)[0x7f2130adfbfb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76fc6)[0x7f2130ae5fc6]
/lib/x86_64-linux-gnu/libc.so.6(+0x7780e)[0x7f2130ae680e]
/usr/local/lib/libbson-1.0.so.0(bson_free+0x1c)[0x7f212196b2c9]
/usr/local/lib/libbson-1.0.so.0(bson_destroy+0x79)[0x7f212195992a]
/usr/local/lib/libmongoc-1.0.so.0(_mongoc_cursor_destroy+0xb5)[0x7f2121bb2b45]
/usr/lib/postgresql/10/lib/mongo_fdw.so(MongoAggregateCount+0xed)[0x7f2121e16f4d]
/usr/lib/postgresql/10/lib/mongo_fdw.so(+0x9e40)[0x7f2121e17e40]
/usr/lib/postgresql/10/lib/mongo_fdw.so(+0xb5c8)[0x7f2121e195c8]
postgres: postgres postgres [local] SELECT(+0x2b928b)[0x55bc04f7228b]
postgres: postgres postgres [local] SELECT(make_one_rel+0x10e)[0x55bc04f7345e]
postgres: postgres postgres [local] SELECT(query_planner+0x198)[0x55bc04f912e8]
postgres: postgres postgres [local] SELECT(+0x2dae28)[0x55bc04f93e28]
postgres: postgres postgres [local] SELECT(subquery_planner+0x8b6)[0x55bc04f96e76]
postgres: postgres postgres [local] SELECT(standard_planner+0x11b)[0x55bc04f97d0b]
postgres: postgres postgres [local] SELECT(pg_plan_query+0x20)[0x55bc05035700]
postgres: postgres postgres [local] SELECT(pg_plan_queries+0x46)[0x55bc050357d6]
postgres: postgres postgres [local] SELECT(+0x37ccfe)[0x55bc05035cfe]
postgres: postgres postgres [local] SELECT(PostgresMain+0x1a4f)[0x55bc050379cf]
postgres: postgres postgres [local] SELECT(+0xb3699)[0x55bc04d6c699]
postgres: postgres postgres [local] SELECT(PostmasterMain+0xfea)[0x55bc04fc707a]
postgres: postgres postgres [local] SELECT(main+0x854)[0x55bc04d6dc74]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f2130a8f2e1]
postgres: postgres postgres [local] SELECT(_start+0x2a)[0x55bc04d6dd2a]
======= Memory map: ========
55bc04cb9000-55bc05395000 r-xp 00000000 08:01 2098395                    /usr/lib/postgresql/10/bin/postgres
55bc05595000-55bc055b7000 r--p 006dc000 08:01 2098395                    /usr/lib/postgresql/10/bin/postgres
55bc055b7000-55bc055c4000 rw-p 006fe000 08:01 2098395                    /usr/lib/postgresql/10/bin/postgres
55bc055c4000-55bc05638000 rw-p 00000000 00:00 0 
55bc05a34000-55bc05aa7000 rw-p 00000000 00:00 0                          [heap]
55bc05aa7000-55bc05b6f000 rw-p 00000000 00:00 0                          [heap]
7f211c000000-7f211c021000 rw-p 00000000 00:00 0 
7f211c021000-7f2120000000 ---p 00000000 00:00 0 
7f2121380000-7f2121534000 r-xp 00000000 08:01 1971300                    /usr/lib/x86_64-linux-gnu/libdb-5.3.so
7f2121534000-7f2121734000 ---p 001b4000 08:01 1971300                    /usr/lib/x86_64-linux-gnu/libdb-5.3.so
7f2121734000-7f212173b000 r--p 001b4000 08:01 1971300                    /usr/lib/x86_64-linux-gnu/libdb-5.3.so
7f212173b000-7f212173e000 rw-p 001bb000 08:01 1971300                    /usr/lib/x86_64-linux-gnu/libdb-5.3.so
7f212173e000-7f2121744000 r-xp 00000000 08:01 135647                     /usr/lib/x86_64-linux-gnu/sasl2/libsasldb.so.2.0.25
7f2121744000-7f2121943000 ---p 00006000 08:01 135647                     /usr/lib/x86_64-linux-gnu/sasl2/libsasldb.so.2.0.25
7f2121943000-7f2121944000 r--p 00005000 08:01 135647                     /usr/lib/x86_64-linux-gnu/sasl2/libsasldb.so.2.0.25
7f2121944000-7f2121945000 rw-p 00006000 08:01 135647                     /usr/lib/x86_64-linux-gnu/sasl2/libsasldb.so.2.0.25
7f2121945000-7f212197f000 r-xp 00000000 08:01 3284107                    /usr/local/lib/libbson-1.0.so.0.0.0
7f212197f000-7f2121b7e000 ---p 0003a000 08:01 3284107                    /usr/local/lib/libbson-1.0.so.0.0.0
7f2121b7e000-7f2121b7f000 r--p 00039000 08:01 3284107                    /usr/local/lib/libbson-1.0.so.0.0.0
7f2121b7f000-7f2121b83000 rw-p 0003a000 08:01 3284107                    /usr/local/lib/libbson-1.0.so.0.0.0
7f2121b83000-7f2121b89000 rw-p 00000000 00:00 0 
7f2121b89000-7f2121c0c000 r-xp 00000000 08:01 3293781                    /usr/local/lib/libmongoc-1.0.so.0.0.0
7f2121c0c000-7f2121e0b000 ---p 00083000 08:01 3293781                    /usr/local/lib/libmongoc-1.0.so.0.0.0
7f2121e0b000-7f2121e0c000 r--p 00082000 08:01 3293781                    /usr/local/lib/libmongoc-1.0.so.0.0.0
7f2121e0c000-7f2121e0d000 rw-p 00083000 08:01 3293781                    /usr/local/lib/libmongoc-1.0.so.0.0.0
7f2121e0d000-7f2121e0e000 rw-p 00000000 00:00 0 
7f2121e0e000-7f2121e24000 r-xp 00000000 08:01 3280426                    /usr/lib/postgresql/10/lib/mongo_fdw.so
7f2121e24000-7f2122024000 ---p 00016000 08:01 3280426                    /usr/lib/postgresql/10/lib/mongo_fdw.so
7f2122024000-7f2122025000 r--p 00016000 08:01 3280426                    /usr/lib/postgresql/10/lib/mongo_fdw.so
7f2122025000-7f2122026000 rw-p 00017000 08:01 3280426                    /usr/lib/postgresql/10/lib/mongo_fdw.so
7f2122026000-7f2122030000 r-xp 00000000 08:01 1970602                    /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f2122030000-7f2122230000 ---p 0000a000 08:01 1970602                    /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f2122230000-7f2122231000 r--p 0000a000 08:01 1970602                    /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f2122231000-7f2122232000 rw-p 0000b000 08:01 1970602                    /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f2122232000-7f2122238000 rw-p 00000000 00:00 0 
7f2122238000-7f212afe0000 rw-s 00000000 00:05 427941                     /dev/zero (deleted)
7f212afe0000-7f212b17b000 r--p 00000000 08:01 1312797                    /usr/lib/locale/locale-archive
7f212b17b000-7f212b182000 r-xp 00000000 08:01 135618                     /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f212b182000-7f212b382000 ---p 00007000 08:01 135618                     /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f212b382000-7f212b383000 r--p 00007000 08:01 135618                     /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f212b383000-7f212b384000 rw-p 00008000 08:01 135618                     /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f212b384000-7f212b397000 r-xp 00000000 08:01 1970584                    /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
7f212b397000-7f212b596000 ---p 00013000 08:01 1970584                    /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
7f212b596000-7f212b597000 r--p 00012000 08:01 1970584                    /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
7f212b597000-7f212b598000 rw-p 00013000 08:01 1970584                    /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
7f212b598000-7f212b60a000 r-xp 00000000 08:01 1970618                    /lib/x86_64-linux-gnu/libpcre.so.3.13.3
7f212b60a000-7f212b809000 ---p 00072000 08:01 1970618                    /lib/x86_64-linux-gnu/libpcre.so.3.13.3
7f212b809000-7f212b80a000 r--p 00071000 08:01 1970618                    /lib/x86_64-linux-gnu/libpcre.so.3.13.3
7f212b80a000-7f212b80b000 rw-p 00072000 08:01 1970618                    /lib/x86_64-linux-gnu/libpcre.so.3.13.3
7f212b80b000-7f212b88c000 r-xp 00000000 08:01 135620                     /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f212b88c000-7f212ba8c000 ---p 00081000 08:01 135620                     /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f212ba8c000-7f212ba8d000 r--p 00081000 08:01 135620                     /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f212ba8d000-7f212ba8e000 rw-p 00082000 08:01 135620                     /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2
7f212ba8e000-7f212bac1000 r-xp 00000000 08:01 135624                     /usr/lib/x86_64-linux-gnu/libhogweed.so.4.3
7f212bac1000-7f212bcc1000 ---p 00033000 08:01 135624                     /usr/lib/x86_64-linux-gnu/libhogweed.so.4.3
7f212bcc1000-7f212bcc2000 r--p 00033000 08:01 135624                     /usr/lib/x86_64-linux-gnu/libhogweed.so.4.3
7f212bcc2000-7f212bcc3000 rw-p 00034000 08:01 135624                     /usr/lib/x86_64-linux-gnu/libhogweed.so.4.3
7f212bcc3000-7f212bcf8000 r-xp 00000000 08:01 135633                     /usr/lib/x86_64-linux-gnu/libnettle.so.6.3
7f212bcf8000-7f212bef7000 ---p 00035000 08:01 135633                     /usr/lib/x86_64-linux-gnu/libnettle.so.6.3
7f212bef7000-7f212bef9000 r--p 00034000 08:01 135633                     /usr/lib/x86_64-linux-gnu/libnettle.so.6.3
7f212bef9000-7f212befa000 rw-p 00036000 08:01 135633                     /usr/lib/x86_64-linux-gnu/libnettle.so.6.3
7f212befa000-7f212bf0b000 r-xp 00000000 08:01 135643                     /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.3
7f212bf0b000-7f212c10b000 ---p 00011000 08:01 135643                     /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.3
7f212c10b000-7f212c10c000 r--p 00011000 08:01 135643                     /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.3
7f212c10c000-7f212c10d000 rw-p 00012000 08:01 135643                     /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.3
7f212c10d000-7f212c13f000 r-xp 00000000 08:01 4071296                    /lib/x86_64-linux-gnu/libidn.so.11.6.16
7f212c13f000-7f212c33f000 ---p 00032000 08:01 4071296                    /lib/x86_64-linux-gnu/libidn.so.11.6.16
7f212c33f000-7f212c340000 r--p 00032000 08:01 4071296                    /lib/x86_64-linux-gnu/libidn.so.11.6.16
7f212c340000-7f212c341000 rw-p 00033000 08:01 4071296                    /lib/x86_64-linux-gnu/libidn.so.11.6.16
7f212c341000-7f212c39b000 r-xp 00000000 08:01 135637                     /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.2.0
7f212c39b000-7f212c59a000 ---p 0005a000 08:01 135637                     /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.2.0
7f212c59a000-7f212c5a4000 r--p 00059000 08:01 135637                     /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.2.0
7f212c5a4000-7f212c5a6000 rw-p 00063000 08:01 135637                     /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.2.0
7f212c5a6000-7f212c5aa000 r-xp 00000000 08:01 1970565                    /lib/x86_64-linux-gnu/libcap-ng.so.0.0.0
7f212c5aa000-7f212c7aa000 ---p 00004000 08:01 1970565                    /lib/x86_64-linux-gnu/libcap-ng.so.0.0.0
7f212c7aa000-7f212c7ab000 r--p 00004000 08:01 1970565                    /lib/x86_64-linux-gnu/libcap-ng.so.0.0.0
7f212c7ab000-7f212c7ac000 rw-p 00005000 08:01 1970565                    /lib/x86_64-linux-gnu/libcap-ng.so.0.0.0
7f212c7ac000-7f212c8b3000 r-xp 00000000 08:01 3149543                    /lib/x86_64-linux-gnu/libgcrypt.so.20.1.6
7f212c8b3000-7f212cab3000 ---p 00107000 08:01 3149543                    /lib/x86_64-linux-gnu/libgcrypt.so.20.1.6
7f212cab3000-7f212cab5000 r--p 00107000 08:01 3149543                    /lib/x86_64-linux-gnu/libgcrypt.so.20.1.6
7f212cab5000-7f212cabc000 rw-p 00109000 08:01 3149543                    /lib/x86_64-linux-gnu/libgcrypt.so.20.1.6
7f212cabc000-7f212cacd000 r-xp 00000000 08:01 1971306                    /usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
7f212cacd000-7f212cccc000 ---p 00011000 08:01 1971306                    /usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
7f212cccc000-7f212cccd000 r--p 00010000 08:01 1971306                    /usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
7f212cccd000-7f212ccce000 rw-p 00011000 08:01 1971306                    /usr/lib/x86_64-linux-gnu/liblz4.so.1.7.1
7f212ccce000-7f212ccf3000 r-xp 00000000 08:01 1970625                    /lib/x86_64-linux-gnu/libselinux.so.1
7f212ccf3000-7f212cef2000 ---p 00025000 08:01 1970625                    /lib/x86_64-linux-gnu/libselinux.so.1
7f212cef2000-7f212cef3000 r--p 00024000 08:01 1970625                    /lib/x86_64-linux-gnu/libselinux.so.1
7f212cef3000-7f212cef4000 rw-p 00025000 08:01 1970625                    /lib/x86_64-linux-gnu/libselinux.so.1
7f212cef4000-7f212cef6000 rw-p 00000000 00:00 0 
7f212cef6000-7f212cf0c000 r-xp 00000000 08:01 1970580                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f212cf0c000-7f212d10b000 ---p 00016000 08:01 1970580                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f212d10b000-7f212d10c000 r--p 00015000 08:01 1970580                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f212d10c000-7f212d10d000 rw-p 00016000 08:01 1970580                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f212d10d000-7f212d27f000 r-xp 00000000 08:01 1971315                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7f212d27f000-7f212d47f000 ---p 00172000 08:01 1971315                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7f212d47f000-7f212d489000 r--p 00172000 08:01 1971315                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7f212d489000-7f212d48b000 rw-p 0017c000 08:01 1971315                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7f212d48b000-7f212d48f000 rw-p 00000000 00:00 0 
7f212d48f000-7f212d619000 r-xp 00000000 08:01 135622                     /usr/lib/x86_64-linux-gnu/libgnutls.so.30.13.1
7f212d619000-7f212d819000 ---p 0018a000 08:01 135622                     /usr/lib/x86_64-linux-gnu/libgnutls.so.30.13.1
7f212d819000-7f212d826000 r--p 0018a000 08:01 135622                     /usr/lib/x86_64-linux-gnu/libgnutls.so.30.13.1
7f212d826000-7f212d827000 rw-p 00197000 08:01 135622                     /usr/lib/x86_64-linux-gnu/libgnutls.so.30.13.1
7f212d827000-7f212d828000 rw-p 00000000 00:00 0 
7f212d828000-7f212d842000 r-xp 00000000 08:01 135639                     /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
7f212d842000-7f212da41000 ---p 0001a000 08:01 135639                     /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
7f212da41000-7f212da42000 r--p 00019000 08:01 135639                     /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
7f212da42000-7f212da43000 rw-p 0001a000 08:01 135639                     /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
7f212da43000-7f212da50000 r-xp 00000000 08:01 135628                     /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.7
7f212da50000-7f212dc50000 ---p 0000d000 08:01 135628                     /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.7
7f212dc50000-7f212dc51000 r--p 0000d000 08:01 135628                     /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.7
7f212dc51000-7f212dc52000 rw-p 0000e000 08:01 135628                     /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.7
7f212dc52000-7f212dc66000 r-xp 00000000 08:01 1970621                    /lib/x86_64-linux-gnu/libresolv-2.24.so
7f212dc66000-7f212de65000 ---p 00014000 08:01 1970621                    /lib/x86_64-linux-gnu/libresolv-2.24.so
7f212de65000-7f212de66000 r--p 00013000 08:01 1970621                    /lib/x86_64-linux-gnu/libresolv-2.24.so
7f212de66000-7f212de67000 rw-p 00014000 08:01 1970621                    /lib/x86_64-linux-gnu/libresolv-2.24.so
7f212de67000-7f212de69000 rw-p 00000000 00:00 0 
7f212de69000-7f212de6c000 r-xp 00000000 08:01 2098206                    /lib/x86_64-linux-gnu/libkeyutils.so.1.5
7f212de6c000-7f212e06b000 ---p 00003000 08:01 2098206                    /lib/x86_64-linux-gnu/libkeyutils.so.1.5
7f212e06b000-7f212e06c000 r--p 00002000 08:01 2098206                    /lib/x86_64-linux-gnu/libkeyutils.so.1.5
7f212e06c000-7f212e06d000 rw-p 00003000 08:01 2098206                    /lib/x86_64-linux-gnu/libkeyutils.so.1.5
7f212e06d000-7f212e078000 r-xp 00000000 08:01 2101049                    /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7f212e078000-7f212e277000 ---p 0000b000 08:01 2101049                    /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7f212e277000-7f212e278000 r--p 0000a000 08:01 2101049                    /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7f212e278000-7f212e279000 rw-p 0000b000 08:01 2101049                    /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7f212e279000-7f212e27c000 r-xp 00000000 08:01 1970569                    /lib/x86_64-linux-gnu/libcom_err.so.2.1
7f212e27c000-7f212e47b000 ---p 00003000 08:01 1970569                    /lib/x86_64-linux-gnu/libcom_err.so.2.1
7f212e47b000-7f212e47c000 r--p 00002000 08:01 1970569                    /lib/x86_64-linux-gnu/libcom_err.so.2.1
7f212e47c000-7f212e47d000 rw-p 00003000 08:01 1970569                    /lib/x86_64-linux-gnu/libcom_err.so.2.1
7f212e47d000-7f212e4ac000 r-xp 00000000 08:01 2101045                    /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7f212e4ac000-7f212e6ac000 ---p 0002f000 08:01 2101045                    /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7f212e6ac000-7f212e6ae000 r--p 0002f000 08:01 2101045                    /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7f212e6ae000-7f212e6af000 rw-p 00031000 08:01 2101045                    /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7f212e6af000-7f212e6b0000 rw-p 00000000 00:00 0 
7f212e6b0000-7f212e779000 r-xp 00000000 08:01 2101047                    /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7f212e779000-7f212e979000 ---p 000c9000 08:01 2101047                    /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7f212e979000-7f212e987000 r--p 000c9000 08:01 2101047                    /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7f212e987000-7f212e98a000 rw-p 000d7000 08:01 2101047                    /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7f212e98a000-7f212e9a7000 r-xp 00000000 08:01 1970556                    /lib/x86_64-linux-gnu/libaudit.so.1.0.0
7f212e9a7000-7f212eba6000 ---p 0001d000 08:01 1970556                    /lib/x86_64-linux-gnu/libaudit.so.1.0.0
7f212eba6000-7f212eba7000 r--p 0001c000 08:01 1970556                    /lib/x86_64-linux-gnu/libaudit.so.1.0.0
7f212eba7000-7f212eba8000 rw-p 0001d000 08:01 1970556                    /lib/x86_64-linux-gnu/libaudit.so.1.0.0
7f212eba8000-7f212ebb2000 rw-p 00000000 00:00 0 
7f212ebb2000-7f212ebd7000 r-xp 00000000 08:01 1970586                    /lib/x86_64-linux-gnu/liblzma.so.5.2.2
7f212ebd7000-7f212edd6000 ---p 00025000 08:01 1970586                    /lib/x86_64-linux-gnu/liblzma.so.5.2.2
7f212edd6000-7f212edd7000 r--p 00024000 08:01 1970586                    /lib/x86_64-linux-gnu/liblzma.so.5.2.2
7f212edd7000-7f212edd8000 rw-p 00025000 08:01 1970586                    /lib/x86_64-linux-gnu/liblzma.so.5.2.2
7f212edd8000-7f212edf1000 r-xp 00000000 08:01 1970644                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7f212edf1000-7f212eff0000 ---p 00019000 08:01 1970644                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7f212eff0000-7f212eff1000 r--p 00018000 08:01 1970644                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7f212eff1000-7f212eff2000 rw-p 00019000 08:01 1970644                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7f212eff2000-7f213086e000 r-xp 00000000 08:01 2101029                    /usr/lib/x86_64-linux-gnu/libicudata.so.57.1
7f213086e000-7f2130a6d000 ---p 0187c000 08:01 2101029                    /usr/lib/x86_64-linux-gnu/libicudata.so.57.1
7f2130a6d000-7f2130a6e000 r--p 0187b000 08:01 2101029                    /usr/lib/x86_64-linux-gnu/libicudata.so.57.1
7f2130a6e000-7f2130a6f000 rw-p 0187c000 08:01 2101029                    /usr/lib/x86_64-linux-gnu/libicudata.so.57.1
7f2130a6f000-7f2130c04000 r-xp 00000000 08:01 1970562                    /lib/x86_64-linux-gnu/libc-2.24.so
7f2130c04000-7f2130e04000 ---p 00195000 08:01 1970562                    /lib/x86_64-linux-gnu/libc-2.24.so
7f2130e04000-7f2130e08000 r--p 00195000 08:01 1970562                    /lib/x86_64-linux-gnu/libc-2.24.so
7f2130e08000-7f2130e0a000 rw-p 00199000 08:01 1970562                    /lib/x86_64-linux-gnu/libc-2.24.so
7f2130e0a000-7f2130e0e000 rw-p 00000000 00:00 0 
7f2130e0e000-7f2130fa2000 r-xp 00000000 08:01 2101043                    /usr/lib/x86_64-linux-gnu/libicuuc.so.57.1
7f2130fa2000-7f21311a1000 ---p 00194000 08:01 2101043                    /usr/lib/x86_64-linux-gnu/libicuuc.so.57.1
7f21311a1000-7f21311b3000 r--p 00193000 08:01 2101043                    /usr/lib/x86_64-linux-gnu/libicuuc.so.57.1
7f21311b3000-7f21311b4000 rw-p 001a5000 08:01 2101043                    /usr/lib/x86_64-linux-gnu/libicuuc.so.57.1
7f21311b4000-7f21311b6000 rw-p 00000000 00:00 0 
7f21311b6000-7f2131421000 r-xp 00000000 08:01 2101031                    /usr/lib/x86_64-linux-gnu/libicui18n.so.57.1
7f2131421000-7f2131620000 ---p 0026b000 08:01 2101031                    /usr/lib/x86_64-linux-gnu/libicui18n.so.57.1
7f2131620000-7f213162d000 r--p 0026a000 08:01 2101031                    /usr/lib/x86_64-linux-gnu/libicui18n.so.57.1
7f213162d000-7f213162f000 rw-p 00277000 08:01 2101031                    /usr/lib/x86_64-linux-gnu/libicui18n.so.57.1
7f213162f000-7f2131630000 rw-p 00000000 00:00 0 
7f2131630000-7f213167d000 r-xp 00000000 08:01 135631                     /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.7
7f213167d000-7f213187c000 ---p 0004d000 08:01 135631                     /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.7
7f213187c000-7f213187e000 r--p 0004c000 08:01 135631                     /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.7
7f213187e000-7f213187f000 rw-p 0004e000 08:01 135631                     /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.7
7f213187f000-7f2131881000 rw-p 00000000 00:00 0 
7f2131881000-7f2131984000 r-xp 00000000 08:01 1970587                    /lib/x86_64-linux-gnu/libm-2.24.so
7f2131984000-7f2131b83000 ---p 00103000 08:01 1970587                    /lib/x86_64-linux-gnu/libm-2.24.so
7f2131b83000-7f2131b84000 r--p 00102000 08:01 1970587                    /lib/x86_64-linux-gnu/libm-2.24.so
7f2131b84000-7f2131b85000 rw-p 00103000 08:01 1970587                    /lib/x86_64-linux-gnu/libm-2.24.so
7f2131b85000-7f2131b88000 r-xp 00000000 08:01 1970572                    /lib/x86_64-linux-gnu/libdl-2.24.so
7f2131b88000-7f2131d87000 ---p 00003000 08:01 1970572                    /lib/x86_64-linux-gnu/libdl-2.24.so
7f2131d87000-7f2131d88000 r--p 00002000 08:01 1970572                    /lib/x86_64-linux-gnu/libdl-2.24.so
7f2131d88000-7f2131d89000 rw-p 00003000 08:01 1970572                    /lib/x86_64-linux-gnu/libdl-2.24.so
7f2131d89000-7f2131d90000 r-xp 00000000 08:01 1970623                    /lib/x86_64-linux-gnu/librt-2.24.so
7f2131d90000-7f2131f8f000 ---p 00007000 08:01 1970623                    /lib/x86_64-linux-gnu/librt-2.24.so
7f2131f8f000-7f2131f90000 r--p 00006000 08:01 1970623                    /lib/x86_64-linux-gnu/librt-2.24.so
7f2131f90000-7f2131f91000 rw-p 00007000 08:01 1970623                    /lib/x86_64-linux-gnu/librt-2.24.so
7f2131f91000-7f2131fd9000 r-xp 00000000 08:01 2101022                    /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7f2131fd9000-7f21321d8000 ---p 00048000 08:01 2101022                    /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7f21321d8000-7f21321da000 r--p 00047000 08:01 2101022                    /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7f21321da000-7f21321dc000 rw-p 00049000 08:01 2101022                    /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7f21321dc000-7f2132441000 r-xp 00000000 08:01 2101005                    /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
7f2132441000-7f2132640000 ---p 00265000 08:01 2101005                    /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
7f2132640000-7f213265e000 r--p 00264000 08:01 2101005                    /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
7f213265e000-7f213266c000 rw-p 00282000 08:01 2101005                    /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
7f213266c000-7f213266f000 rw-p 00000000 00:00 0 
7f213266f000-7f21326d1000 r-xp 00000000 08:01 2101098                    /usr/lib/x86_64-linux-gnu/libssl.so.1.1
7f21326d1000-7f21328d1000 ---p 00062000 08:01 2101098                    /usr/lib/x86_64-linux-gnu/libssl.so.1.1
7f21328d1000-7f21328d5000 r--p 00062000 08:01 2101098                    /usr/lib/x86_64-linux-gnu/libssl.so.1.1
7f21328d5000-7f21328db000 rw-p 00066000 08:01 2101098                    /usr/lib/x86_64-linux-gnu/libssl.so.1.1
7f21328db000-7f21328e8000 r-xp 00000000 08:01 1970611                    /lib/x86_64-linux-gnu/libpam.so.0.83.1
7f21328e8000-7f2132ae7000 ---p 0000d000 08:01 1970611                    /lib/x86_64-linux-gnu/libpam.so.0.83.1
7f2132ae7000-7f2132ae8000 r--p 0000c000 08:01 1970611                    /lib/x86_64-linux-gnu/libpam.so.0.83.1
7f2132ae8000-7f2132ae9000 rw-p 0000d000 08:01 1970611                    /lib/x86_64-linux-gnu/libpam.so.0.83.1
7f2132ae9000-7f2132c99000 r-xp 00000000 08:01 2101102                    /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.4
7f2132c99000-7f2132e99000 ---p 001b0000 08:01 2101102                    /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.4
7f2132e99000-7f2132ea1000 r--p 001b0000 08:01 2101102                    /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.4
7f2132ea1000-7f2132ea3000 rw-p 001b8000 08:01 2101102                    /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.4
7f2132ea3000-7f2132ea4000 rw-p 00000000 00:00 0 
7f2132ea4000-7f2132ebc000 r-xp 00000000 08:01 1970619                    /lib/x86_64-linux-gnu/libpthread-2.24.so
7f2132ebc000-7f21330bb000 ---p 00018000 08:01 1970619                    /lib/x86_64-linux-gnu/libpthread-2.24.so
7f21330bb000-7f21330bc000 r--p 00017000 08:01 1970619                    /lib/x86_64-linux-gnu/libpthread-2.24.so
7f21330bc000-7f21330bd000 rw-p 00018000 08:01 1970619                    /lib/x86_64-linux-gnu/libpthread-2.24.so
7f21330bd000-7f21330c1000 rw-p 00000000 00:00 0 
7f21330c1000-7f21330e4000 r-xp 00000000 08:01 1970544                    /lib/x86_64-linux-gnu/ld-2.24.so
7f2133159000-7f213323d000 rw-p 00000000 00:00 0 
7f213323d000-7f213324e000 rw-p 00000000 00:00 0 
7f213324e000-7f21332d2000 r-xp 00000000 08:01 1970632                    /lib/x86_64-linux-gnu/libsystemd.so.0.17.0
7f21332d2000-7f21332d3000 ---p 00084000 08:01 1970632                    /lib/x86_64-linux-gnu/libsystemd.so.0.17.0
7f21332d3000-7f21332d6000 r--p 00084000 08:01 1970632                    /lib/x86_64-linux-gnu/libsystemd.so.0.17.0
7f21332d6000-7f21332d7000 rw-p 00087000 08:01 1970632                    /lib/x86_64-linux-gnu/libsystemd.so.0.17.0
7f21332d7000-7f21332dc000 rw-p 00000000 00:00 0 
7f21332dc000-7f21332de000 rw-s 00000000 00:88 425769                     /dev/shm/mongoc-95
7f21332de000-7f21332e0000 rw-s 00000000 00:88 427943                     /dev/shm/PostgreSQL.843309791
7f21332e0000-7f21332e1000 rw-s 00000000 00:05 196608                     /SYSV0052e2c1 (deleted)
7f21332e1000-7f21332e4000 rw-p 00000000 00:00 0 
7f21332e4000-7f21332e5000 r--p 00023000 08:01 1970544                    /lib/x86_64-linux-gnu/ld-2.24.so
7f21332e5000-7f21332e6000 rw-p 00024000 08:01 1970544                    /lib/x86_64-linux-gnu/ld-2.24.so
7f21332e6000-7f21332e7000 rw-p 00000000 00:00 0 
7ffcda55f000-7ffcda580000 rw-p 00000000 00:00 0                          [stack]
7ffcda586000-7ffcda588000 r--p 00000000 00:00 0                          [vvar]
7ffcda588000-7ffcda58a000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
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: 2018-06-18 10:06:42.941 UTC [9] LOG:  server process (PID 95) was terminated by signal 6: Aborted
2018-06-18 10:06:42.941 UTC [9] DETAIL:  Failed process was running: SELECT * FROM users;
2018-06-18 10:06:42.941 UTC [9] LOG:  terminating any other active server processes
2018-06-18 10:06:42.942 UTC [96] FATAL:  the database system is in recovery mode
2018-06-18 10:06:42.943 UTC [84] WARNING:  terminating connection because of crash of another server process
2018-06-18 10:06:42.943 UTC [84] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2018-06-18 10:06:42.943 UTC [84] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
Failed.
!> 2018-06-18 10:06:42.946 UTC [9] LOG:  all server processes terminated; reinitializing
2018-06-18 10:06:42.955 UTC [97] LOG:  database system was interrupted; last known up at 2018-06-18 09:38:49 UTC
2018-06-18 10:06:43.029 UTC [97] LOG:  database system was not properly shut down; automatic recovery in progress
2018-06-18 10:06:43.031 UTC [97] LOG:  redo starts at 0/165A270
2018-06-18 10:06:43.032 UTC [97] LOG:  invalid record length at 0/1676BF8: wanted 24, got 0
2018-06-18 10:06:43.032 UTC [97] LOG:  redo done at 0/1676A40
2018-06-18 10:06:43.032 UTC [97] LOG:  last completed transaction was at log time 2018-06-18 10:06:38.874457+00
2018-06-18 10:06:43.045 UTC [9] LOG:  database system is ready to accept connections

If I run mongo 3.4 everything works like a charm

# start mongo 3.4
docker run --rm --name mongo -e "MONGO_INITDB_ROOT_USERNAME=root" -e "MONGO_INITDB_ROOT_PASSWORD=example" -d mongo:3.4

# creating the foreign table like above

# select users
postgres=# SELECT * FROM users;
           _id            
--------------------------
 5b277779ab8cf1679af0f63d
(1 row)

Does this extension support mongo 3.6?

tbutts commented 6 years ago

I'm also experiencing issues with Mongo 3.6, which downgrading to 3.4 allowed me to bypass. In my case, simple queries like SELECT * FROM users worked fine, while INSERT would occasionally fail, and aggregates would consistently fail. My stacktraces follow a similar path, and they all seem to go through MongoGetForeignPaths -> ForeignTableDocumentCount -> MongoAggregateCount and then cause a corruption on either bson_copy_to or bson_destroy.

I'm running the latest mongo_fdw with the Makefile tweaked to use dependencies I installed at the system level through the Arch Linux repos:

If you need any more info, I'd be happy to help repro. Thanks for maintaining the project!

vaibhavdalvi93 commented 2 years ago

Thanks, @freshfx and @tbutts for reporting an issue here.

Currently, we do support upto MongoDB 4.4 and so, MongoDB 3.6 is also supported. Can you please check if reported issue is been resolved or not? If it still exists please let us know otherwise can you please close this ticket?

tbutts commented 2 years ago

Sadly I can't be of much help as I no longer have a need for the mongo_fdw or an env to test in. But thank you for looking at this issue again.

jeevanchalke commented 2 years ago

Thanks, @tbutts. Closing.