[Serusers] threading weirdness?

Nils Ohlmeier nils at ohlmeier.de
Sun Mar 2 09:06:36 CET 2003


Hi Greg,

On Sunday 02 March 2003 07:59, Greg Fausak wrote:
> Hi,
> Mar  1 23:59:49 rave ser[1803]: db_init():
> sql://USER:PASSWORD@humpty.august.net:5432/THEDBNAME Mar  1 23:59:49 rave
> ser[1803]: connect_db(): here we go
> Mar  1 23:59:49 rave ser[1803]: connect_db(): we are connected
> /tmp/debug.1803.out Mar  1 23:59:49 rave ser[1804]: db_close():
> disconnect_db()
> Mar  1 23:59:49 rave ser[1804]: disconnect_db(): entry
> Mar  1 23:59:49 rave ser[1804]: disconnect_db(): PQfinish()
> Mar  1 23:59:49 rave ser[1804]: db_close(): free self
> Mar  1 23:59:49 rave ser[1804]: db_init():
> sql://USER:PASSWORD@humpty.august.net:5432/THEDBNAME Mar  1 23:59:49 rave
> ser[1804]: connect_db(): here we go
> Mar  1 23:59:49 rave ser[1805]: db_close(): disconnect_db()
> Mar  1 23:59:49 rave ser[1805]: disconnect_db(): entry
> Mar  1 23:59:49 rave ser[1805]: disconnect_db(): PQfinish()
> Mar  1 23:59:49 rave ser[1805]: db_close(): free self
> Mar  1 23:59:49 rave ser[1805]: db_init():
> sql://USER:PASSWORD@humpty.august.net:5432/THEDBNAME Mar  1 23:59:49 rave
> ser[1805]: connect_db(): here we go
> Mar  1 23:59:49 rave ser[1806]: db_close(): disconnect_db()
> Mar  1 23:59:49 rave ser[1806]: disconnect_db(): entry
> Mar  1 23:59:49 rave ser[1806]: disconnect_db(): PQfinish()
> Mar  1 23:59:49 rave ser[1806]: db_close(): free self
> Mar  1 23:59:49 rave ser[1804]: connect_db(): we are connected
> /tmp/debug.1804.out Mar  1 23:59:49 rave ser[1806]: db_init():
> sql://USER:PASSWORD@humpty.august.net:5432/THEDBNAME Mar  1 23:59:49 rave
> ser[1804]: db_init(): sql://USER:PASSWORD@humpty.august.net:5432/THEDBNAME
> Mar  1 23:59:49 rave ser[1806]: connect_db(): here we go
> Mar  1 23:59:49 rave ser[1804]: connect_db(): here we go
> Mar  1 23:59:49 rave ser[1805]: connect_db(): we are connected
> /tmp/debug.1805.out Mar  1 23:59:49 rave ser[1805]: db_init():
> sql://USER:PASSWORD@humpty.august.net:5432/THEDBNAME Mar  1 23:59:49 rave
> ser[1805]: connect_db(): here we go
> Mar  1 23:59:49 rave ser[1804]: connect_db(): we are connected
> /tmp/debug.1804.out Mar  1 23:59:50 rave ser[1805]: connect_db(): we are
> connected /tmp/debug.1805.out Mar  1 23:59:50 rave ser[1806]: connect_db():
> we are connected /tmp/debug.1806.out Mar  1 23:59:50 rave ser[1806]:
> db_init(): sql://USER:PASSWORD@humpty.august.net:5432/THEDBNAME Mar  1
> 23:59:50 rave ser[1806]: connect_db(): here we go
> Mar  1 23:59:50 rave ser[1806]: connect_db(): we are connected
> /tmp/debug.1806.out Mar  2 00:00:50 rave ser[1807]: begin_transaction():
> BEGIN error server closed the connection unexpectedly ^IThis probably means
> the server terminated abnormally ^Ibefore or while processing the request.
I think the problem is that a transaction is made from a process which do not 
initalized it's database connection. See below.

> A couple of questions:
> 1) I state 'children=2', but I see 6 'processes'.  I think linux does
>    threads with processes, so am I seeing 2 'processes' with 3 threads per
>    process???
Children means only how many processes are doing the main work: listening on 
the interfaces and porccesing request. Their is also one timer process which 
runs regular commands. And you have fifo activate in your config, this 
results in another process for listening on the fifo. With 'serctl ps' you 
can see which process is for what.
We don't use threads AFAIK. The linux thread scheme isn't very portable.

> 2) the debug output has the process ID and the action being
>    performed.  Either it is way out of order, or the postgres
>    db driver is being asked to do things out of order.
Sorry i don't understand what you mean.

> 3) Why is there all of the db_init(), db_close() stuff??  All of this
>    stuff happens in the first second on startup.  Surely that many opens
>    and closes aren't really needed are they?
Every ser process have to open its own db connection. With this way every 
process can access the db if it needs to. Otherwise we would need one db 
communication process, which would require interprocess communication. Or we 
had to share one connection between multiple processes, which would require a 
lot of locking.

> 4) select statements seem to happen in one thread, and insert/delete
> statements seem to happen in another thread.  What is that about?
I can only think of the initial usrloc load from database at ser startup as 
process which only selects. After this only inserts and deletes should 
happen. But maybe i'm overseeing here something. Jan?

Greetings
  Nils



More information about the sr-users mailing list