June 25th, 2013, 05:37 AM
Disconnect all idle connections
How can I disconnect all idle connections from Firebird?
How to disconnect the user connection?
Currently there is no easy way of doing it. You can bring database to some of shutdown modes, but it affects all users. If you use Classic you can (with some effort) find the users process by detecting the IP address and open database files of that process and simply kill that process. With Super Server it is not possible as the connection is run in a thread of multithreaded SuperServer process.
There are plans for future versions of Firebird to address this. For example, version 2.1 introduces ability to cancel running queries (by deleting the relevant records from MON$STATEMENTS table).
If you just want to take the database offline for maintenance (all users disconnected), you can take database to a shutdown mode using gfix and then rename the database file, so that nobody can connect, not even by chance. On Windows, you won't be able to rename the database file while in use. On Linux, you need to check manually whether the file is in use by using 'fuser' or 'lsof' command. Make sure you run those as 'root' user, as ordinary users cannot detect files opened by other accounts.
See the SYSTEM TABLES (hided) for MON$???????
Last edited by emailx45; July 9th, 2013 at 11:38 AM.
July 11th, 2013, 09:55 AM
From Firebird 2.5 you can use :
to disconnect different connections from the database.
DELETE FROM MON$ATTACHMENTS WHERE MON$ATTACHMENT_ID something