Re: Strange error (Socket command option unknown) - Mailing list pgsql-general

From Doug McNaught
Subject Re: Strange error (Socket command option unknown)
Date
Msg-id m3adgnvxi4.fsf@varsoon.wireboard.com
Whole thread Raw
In response to Strange error (Socket command option unknown)  (Carlos Moreno <moreno@mochima.com>)
List pgsql-general
Carlos Moreno <moreno@mochima.com> writes:

> I wonder if the fact that my app. is multi-threaded
> (logging to database is something that has kind of
> low-priority, and I don't want it to interfere with the
> "main loop" of my app. -- the main loop is basically
> the communications loop, which is critical for the
> responsiveness of my server to the multiple clients).
>
> So, I wonder if I (or postgres??) is doing something
> wrong with the multiple requests??  There are only
> two threads that make any use of the database:
> one that logs to db (i.e., exclusively insert, update,
> and delete commands), and one to process the
> login authentications (users' names and passwords
> are stored in the database, along with related
> information that has to be retrieved at login-time).

If you're using the database from two threads, you should either be
using one DB connection per thread, or protecting the single DB
connection with a mutex lock for the duration of each query.  One
connection per thread is probably simplest.

> So, is it possible that these two threads are "stepping
> on each other's tails"?

Quite possible, unless you're taking steps to prevent it.  Sharing a
single connection between independent threads with no locking is
probably not going to work.

-Doug

pgsql-general by date:

Previous
From: Carlos Moreno
Date:
Subject: Re: Strange error (Socket command option unknown)
Next
From: "erwan ancel"
Date:
Subject: Re: troubles with postgresql