Hi Jeroen, Many thanks for your fast and valuable reply. As I guessed in the beginning, it was poor network programming on my end. Fortunately, I found the problem just now after a long week of debugging. It ended up being what you said in the email: creating and closing lots of short-lived socket connections.
There is nothing wrong with pqxx, it is working smoothly. I can say now that I understand sockets way better ;-) Thanks again, congratulations for the pqxx project, and keep up the good work! kind regards, -Rilson On 8/10/07, Jeroen T. Vermeulen <[EMAIL PROTECTED]> wrote: > > On Fri, August 10, 2007 10:24, Rilson Nascimento wrote: > > > I am using pqxx in a multi-threaded server that connects to a PostgreSQL > > database. I'm experiencing a problem in which my server leaves a bunch > of > > TIME_WAIT socket connection with the PostgreSQL server when it is > running. > > If I remember correctly, those are closed sockets that the OS keeps around > for a while just in case more packets arrive for them. So they should go > away eventually, completely independently of the coming and going of your > program. That part is normal. > > The suspicious part is that so many sockets were opened in the first > place. You're not knowingly creating and closing lots of short-lived > connections? Or even just a lot of long-lived connections? > > The sockets could be by-products of retries (attempt to connect, fail, > close socket, try a new one) but on a localhost connection you generally > either fail or succeed consistently. If a localhost connection fails, the > next attempt won't work either and the program just won't be able to > access the database. > > > > I'm using pqxx's lazyconnection. Actually there is only ONE client > running > > in a loop sending transactions to the server (via tcp socket), which in > > turn connects to the PgSQL database via a lazyconnection (I tried with > the > > usual connection object too). > > The plain "connection" class provides the more useful information: if you > see the same behaviour there, that tells us this is not an obscure problem > in the lazy-connection logic, and that comes as a relief. > > > > I guess this is an effect of poor networking programming (socket > > programming) and/or poor pqxx programming. > > Whatever, What should I do to realize this is not a problem related with > > misusing of pqxx? I mean, I want to be sure I am using pqxx in the right > > fashion to ensure this problem is not caused by pqxx. > > The safest thing as far as threading is concerned is to make sure that no > two threads access the same connection, or other objects belonging to the > same connection, simultaneously. That's more strict than is really > necessary, but it's also relatively easy to maintain. > > > Jeroen > > >
_______________________________________________ Libpqxx-general mailing list Libpqxx-general@gborg.postgresql.org http://gborg.postgresql.org/mailman/listinfo/libpqxx-general