Hi Jeroen, list My problem with sockets is definitely closed. Now my transactions are behaving strangely. I managed to open just one db connection per client, but now I cannot run multiple transactions per connection (it seems). Errors indicating that there is already a transaction open start to arise. Otherwise, if I change the code to create one db connection per transaction I start to see those TIME_WAIT (a lot of them!) connections with the database again. That's a perfect example of a dilemma.
Any thoughts or comment on this? Thank you, -Rilson On 8/10/07, Rilson Nascimento <[EMAIL PROTECTED]> wrote: > > 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