Search Postgresql Archives

Re: Waiting for Disconnect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Wheeler <david@xxxxxxxxxxxxxx> writes:
> I have some tests that create a database, run a bunch of tests against 
> it, and then drop it. But I was running into an issue where I'd get 
> this error even after I disconnected from the test database:

>    ERROR:  source database "foo" is being accessed by other users

Yeah, I've seen this too.  The problem is that the backend you were
using hasn't exited yet when you try to issue the DROP DATABASE.
This is a bit surprising given the small amount of work normally
needed for a backend to exit.  (If it has to drop temp tables or
something, that might be another story, but I've seen it happen
with no such cleanup work needed.)

As best I can tell, it happens because the kernel has simply given
no, none, zero cycles to the orphaned backend, preferring instead
to run your shell, psql, and the postmaster.  I suppose this is
because some scheduler heuristic inside the kernel has decided that
the backend is a "background" process that deserves low priority.
I get the impression that some platforms are more prone to this than
others, which is consistent with the idea that it's a scheduler issue.

The only real solution I know of is to sleep for a little before
trying to issue the DROP DATABASE.  Certainly, adding more database
traffic as you suggest isn't going to improve matters.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
      message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux