Class LockTable

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.sql.ResultSet, java.sql.Wrapper, AwareVTI, VTICosting

    public class LockTable
    extends VTITemplate
    implements VTICosting
    LockTable is a virtual table that shows all locks currently held in the database. This virtual table can be invoked by calling it directly
     select * from SYSCS_DIAG.LOCK_TABLE 

    The LockTable virtual table takes a snap shot of the lock table while the system is in flux, so it is possible that some locks may be in transition state while the snap shot is taken. We choose to do this rather then impose extranous timing restrictions so that the use of this tool will not alter the normal timing and flow of execution in the application.

    The LockTable virtual table has the following columns:

    • XID varchar(15) - not nullable. The transaction id, this can be joined with the TransactionTable virtual table's XID.
    • TYPE varchar(5) - nullable. The type of lock, ROW, TABLE, or LATCH
    • MODE varchar(4) - not nullable. The mode of the lock, "S", "U", "X", "IS", "IX".
      • S is shared lock (N/A to Latch)
      • U is update lock (N/A to Latch)
      • X is exclusive lock
      • IS is intent shared lock (N/A to Latch or Row lock)
      • IX is intent exclusive lock (N/A to Latch or Row lock)
    • TABLENAME varchar(128) - not nullable. The name of the base table the lock is for
    • LOCKNAME varchar(20) - not nullable. The name of the lock
    • STATE varchar(5) - nullable. GRANT or WAIT
    • TABLETYPE varchar(9) - not nullable. 'T' for user table, 'S' for system table
    • LOCKCOUNT varchar(5) - not nullable. Internal lock count.
    • INDEXNAME varchar(128) - normally null. If non-null, a lock is held on the index.
    • Field Detail

      • TABLE_AND_ROWLOCK

        public static final int TABLE_AND_ROWLOCK
        return only table and row locks
        See Also:
        Constant Field Values
      • currentRow

        private java.util.Hashtable currentRow
      • lockTable

        private java.util.Enumeration lockTable
      • wasNull

        private boolean wasNull
      • initialized

        private boolean initialized
      • flag

        private final int flag
      • metadata

        private static final java.sql.ResultSetMetaData metadata
    • Constructor Detail

      • LockTable

        public LockTable()
        The normal way of instantiating a LockTable, equivalent to LockTable(org.apache.derby.diag.LockTable->TABLE_AND_ROWLOCK). Only shows row and table lock and not latches. Latches are generally held for very short duration and are not of interest to Derby users. Only under abnormal circumstances will one be interested in looking at latches.
      • LockTable

        public LockTable​(int flag)
        This call is intrusive and should only be used under the supervision of technical support. Create an instance of the lock table which has transient latches as well as locks.
    • Method Detail

      • getMetaData

        public java.sql.ResultSetMetaData getMetaData()
        Specified by:
        getMetaData in interface java.sql.ResultSet
        Overrides:
        getMetaData in class VTITemplate
        See Also:
        ResultSet.getMetaData()
      • next

        public boolean next()
                     throws java.sql.SQLException
        Specified by:
        next in interface java.sql.ResultSet
        Throws:
        java.sql.SQLException - if no transaction context can be found, or other Derby internal errors are encountered.
        See Also:
        ResultSet.next()
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.ResultSet
        See Also:
        ResultSet.close()
      • getString

        public java.lang.String getString​(int columnNumber)
        All columns in TransactionTable VTI are of String type.
        Specified by:
        getString in interface java.sql.ResultSet
        Overrides:
        getString in class VTITemplate
        See Also:
        ResultSet.getString(int)
      • wasNull

        public boolean wasNull()
        Specified by:
        wasNull in interface java.sql.ResultSet
        Overrides:
        wasNull in class VTITemplate
        See Also:
        ResultSet.wasNull()
      • dumpLock

        private java.util.Hashtable<java.lang.String,​java.lang.Object> dumpLock​(Latch lock)
                                                                               throws StandardException
        Convert the lock information into a hashtable.
        Throws:
        StandardException