Christian Maurer <c.maurer@gmx.at> writes:
>> I wondered whether we needed to introduce a critical section
>> to prevent multiple threads from calling that concurrently,
>> even though its docs allege you shouldn't have to. Perhaps
>> it's thread-safe except on Windows?
> This would explain, why I could not reproduce the error on Red Hat Enterprise Linux.
Are you in a position to try a source-code patch? The attached
is very quick-and-dirty, but if it resolves your problem then
we could turn it into something respectable.
regards, tom lane
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 47a28b0a3a..8906dae892 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -1243,12 +1243,17 @@ libpq_binddomain(void)
#endif
const char *ldir;
+ pglock_thread();
+
/* No relocatable lookup here because the binary could be anywhere */
ldir = getenv("PGLOCALEDIR");
if (!ldir)
ldir = LOCALEDIR;
bindtextdomain(PG_TEXTDOMAIN("libpq"), ldir);
already_bound = true;
+
+ pgunlock_thread();
+
#ifdef WIN32
SetLastError(save_errno);
#else