Skip to content

mongoc-ts-pool.c:191 _try_get(): assertion failed: pthread_mutex_lock ((&pool->mtx)) == 0 #194

@df7cb

Description

@df7cb

@devrimgunduz poked me at pgconf.eu to package mongo_fdw for Debian and I gave it a shot.

The good news is that I got it compiled on trixie-and-newer, the bad news is that it crashes:

create extension mongo_fdw ;
CREATE EXTENSION
create server mongo foreign data wrapper mongo_fdw ;
CREATE SERVER
create user mapping for current_user SERVER mongo ;
CREATE USER MAPPING
CREATE FOREIGN TABLE f_mongo_test (_id name, a int, b varchar) SERVER mongo;
CREATE FOREIGN TABLE
SELECT a, b FROM f_mongo_test ORDER BY 1, 2;
 a │ b 
───┼───
(0 Zeilen)

SELECT a, b FROM f_mongo_test ORDER BY 1, 2;
Server beendete die Verbindung unerwartet
	Das heißt wahrscheinlich, dass der Server abnormal beendete
	bevor oder während die Anweisung bearbeitet wurde.

Mongo log for the last two commands:

{"t":{"$date":"2025-10-28T13:14:43.406+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.17.0.1:41340","isLoadBalanced":false,"uuid":{"uuid":{"$uuid":"7ff1739b-0464-4d73-a850-d14424c4fb65"}},"connectionId":4,"connectionCount":1}}
{"t":{"$date":"2025-10-28T13:14:43.406+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn4","msg":"client metadata","attr":{"remote":"172.17.0.1:41340","client":"conn4","negotiatedCompressors":[],"doc":{"driver":{"name":"mongoc","version":"2.1.2"},"platform":"cfg=0x07235e88e9 posix=200809 stdc=199901 CC=GCC 15.2.0 CFLAGS=\"-g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/mongo-c-driver-2.1.2=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2\" LDFLAGS=\"-Wl,-z,relro -Wl,-z,now -lpthread\"","os":{"type":"Linux"}}}}
{"t":{"$date":"2025-10-28T13:14:43.406+00:00"},"s":"I",  "c":"ACCESS",   "id":10483900,"ctx":"conn4","msg":"Connection not authenticating","attr":{"client":"172.17.0.1:41340","doc":{"driver":{"name":"mongoc","version":"2.1.2"},"platform":"cfg=0x07235e88e9 posix=200809 stdc=199901 CC=GCC 15.2.0 CFLAGS=\"-g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/mongo-c-driver-2.1.2=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2\" LDFLAGS=\"-Wl,-z,relro -Wl,-z,now -lpthread\"","os":{"type":"Linux"}}}}
{"t":{"$date":"2025-10-28T13:14:43.407+00:00"},"s":"I",  "c":"NETWORK",  "id":6788700, "ctx":"conn4","msg":"Received first command on ingress connection since session start or auth handshake","attr":{"elapsedMillis":0}}

{"t":{"$date":"2025-10-28T13:14:47.229+00:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn4","msg":"Connection ended","attr":{"remote":"172.17.0.1:41340","isLoadBalanced":false,"uuid":{"uuid":{"$uuid":"7ff1739b-0464-4d73-a850-d14424c4fb65"}},"connectionId":4,"connectionCount":0}}

PG log:

./src/libmongoc/src/mongoc/mongoc-ts-pool.c:191 _try_get(): assertion failed: pthread_mutex_lock ((&pool->mtx)) == 0
2025-10-28 13:14:47.229 UTC [1291486] LOG:  client backend (PID 1297825) was terminated by signal 6: Aborted
2025-10-28 13:14:47.229 UTC [1291486] DETAIL:  Failed process was running: SELECT a, b FROM f_mongo_test ORDER BY 1, 2;

This is mongo_fdw 5.5.3 on PG 18.0 (cassert enabled) on Debian sid with libmongoc-dev 2.1.2-1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions