Re: Forcing $dbh->disconnect to really disconnect



On 05/21/2008 11:32 PM, Greg Sabino Mullane wrote:
Unfortunately, the disconnect call apparently doesn't really disconnect,
because the dropdb command fails with an error that other users are
still connected to the database.

This works fine for me. It's most likely that you have other clients still
attached to the database. Try seeing who's connected by doing a:

SELECT * FROM pg_stat_activity;
No, there were no other clients connected.

When I look in pg_stat_activity, I see a row with a valid procpid (i.e., it refers to a running postgres process), a blank client_addr, and a client_port value of -1. It appears that the postgres process continues to run for a little while after the client disconnects from it, and that one cannot drop the database until this process exits. So it's just a matter of waiting a little while after the disconnect before trying to do the dropdb command.

Note that I'm not actually convinced the stale row in pg_stat_activity was the one from DBI. In fact, I think it was probably from another external command I ran on the database. So I suspect that in fact, DBI is closing its connection properly, and it's that other command that's not closing it properly and thus causing the process to hang around a little while before exiting. That's just a guess, though.

In any case, thanks for the response.

Jonathan Kamens



Relevant Pages

  • Re: ADO Connection Timeout
    ... so what happens when a connection failure forces one station to revert ... to a local database? ... Further, you *will* have contention issues, Jet does not support record ... to the central server, but you are willing to live with periods where it ...
    (microsoft.public.data.ado)
  • Re: ADO Connection Timeout
    ... When the first test is run, the results are stored in the central database. ... to the central server, but you are willing to live with periods where it ... i.e. a local database or even a text file. ... to function until the connection can be restored to the server. ...
    (microsoft.public.data.ado)
  • Re: ADO Connection Timeout
    ... to the central server, but you are willing to live with periods where it ... i.e. a local database or even a text file. ... to function until the connection can be restored to the server. ...
    (microsoft.public.data.ado)
  • Re: Communicating over the internet
    ... > That way you provide one manner in which to open the database, ... > can keep the connection open and then when someone wants to ... > server as the database and the soap dll connecting with a TCP socket. ... The name of the running program might help. ...
    (microsoft.public.vb.general.discussion)
  • Re: ADO Connection Timeout
    ... much rather write stored procedures and use server side cursors. ... local database, it is vital that I get the information to a central server. ... Once the connection is restored, ...
    (microsoft.public.data.ado)