Re: How do I find out which users are connected to a database
Posted in 1997
In article <330C9507.6C17@sbs.siemens.co.uk>, John Clutterbuck
<john.clutterbuck@sbs.siemens.co.uk> writes
>Sean Wong wrote:
>> I wrote couple of scripts which will work togather and terminate all =
>> sessions which has locked the Informix instance on the environment. As =
>> I have mentioned above, I don't need to check who has locked which =
>> database.
>
>I also have some scripts which work out the users and process IDS
>connected to the informix instance, and also I can find the tables and
>databases actually locked by associating the tblsnum from tbstat -k with
>a select of hex(partnum) from systables in each database.
>
>What I CANNOT do is find a reference to the HDR+S locks with a tblsnum
>of 1000002 and a rowid within the tbstat -k output. These seem to be the
>database connections.
>
Correct, tblsnum of 1000002 is the database tablspace. It holds a
list of databases within the instance (database name,database owner,
data and time database was created,tblspace number of the systables
tblspace for the database (so the tables within the database can
be found/accessed) and flag indicating the logging mode of the
database.
It has a unique index on the database name so you cannot create two
databases with the same name in the one instance. Whenever you connect
to a database you take a shared lock on the database (To stop other
people dropping it whilst you are using it). This means Informix does
not need to check the database still exists each time you access a
table (for performance reasons).
If you execute "LOCK DATABASE <database name> IN EXLUSIVE MODE" you
will find the lock becomes an exclusive lock.
This is documented in the Online Dynamic Server Administrators Guide,
Volume 2 Version 7.1 Pages 43-22/43-23 and 43-69.
The database tblspace is not accessible by any Informix tools
(only the engine) and
. Don't worry about it.
PS If you see locks against tblsnum 10000001 that is the first
tblspace tblspace (See Pages 43-19) which tracks all tblspaces within
the relevant dbspace.
>Does anyone know whther this info can be determined using dbaccess,
>ESQL/C prog etc.
>
>Thanks again in anticipation.
>
>John Clutterbuck
--
David Williams