---
title: "Locks and transactions: lockdb, tranlist, killtran"
description: "Inspect locks with coradb lockdb, list running transactions and their queries with coradb tranlist, and end transactions with coradb killtran."
url: "https://www.coradb.ai/manual/admin/admin_transactions.html"
markdown_url: "https://www.coradb.ai/manual/markdown/admin/admin_transactions.md"
product: "CoraDB"
version: "1.0"
keywords: "coradb lockdb, coradb tranlist, coradb killtran, lock table dump, kill transaction, running queries"
---

# Locks and transactions: lockdb, tranlist, killtran

## lockdb

The **coradb lockdb** utility is used to check the information on the lock being used by the current transaction in the database.

``` bash
coradb lockdb [options] database_name
```

- **coradb**: An integrated utility for the CoraDB service and database management.
- **lockdb**: A command used to check the information on the lock being used by the current transaction in the database.
- *database_name*: The name of the database where lock information of the current transaction is to be checked.

The following example shows how to display lock information of the *testdb* database on a screen without any option.

``` bash
coradb lockdb testdb
```

The following shows \[options\] available with the **coradb lockdb** utility.

**-o, --output-file=FILE**

The **-o** option displays the lock information of the *testdb* database as a output.txt.

``` bash
coradb lockdb -o output.txt testdb
```

### Output contents

The output contents of **coradb lockdb** are divided into three logical sections.

- Server lock settings
- Clients that are accessing the database
- The contents of an object lock table

**Server lock settings**

The first section of the output of **coradb lockdb** is the database lock settings.

``` text
*** Lock Table Dump ***
 Lock Escalation at = 100000, Run Deadlock interval = 0
```

The lock escalation level is 100,000 records, and the interval to detect deadlock is set to 0 seconds.

For a description of the related system parameters, **lock_escalation** and **deadlock_detection_interval**, see [Concurrency/lock-related parameters](https://www.coradb.ai/manual/admin/config_logging.html#concurrencylock-related-parameters).

**Clients that are accessing the database**

The second section of the output of **coradb lockdb** includes information on all clients that are connected to the database. This includes the transaction index, program name, user ID, host name, process ID, isolation level and lock timeout settings of each client.

``` text
Transaction (index 1, corasql, dba@coradbdb|12854)
Isolation COMMITTED READ
Timeout_period : Infinite wait
```

Here, the transaction index is 1, the program name is corasql, the user ID is dba, the host name is coradbdb, the client process identifier is 12854, the isolation level is COMMITTED READ and the lock timeout is unlimited.

A client for which transaction index is 0 is the internal system transaction. It can obtain the lock at a specific time, such as the processing of a checkpoint by a database. In most cases, however, this transaction will not obtain any locks.

Because **coradb lockdb** utility accesses the database to obtain the lock information, the **coradb lockdb** is an independent client and will be output as such.

**Object lock table**

The third section of the output of the **coradb lockdb** includes the contents of the object lock table. It shows which client has the lock for which object in which mode, and which client is waiting for which object in which mode. The first part of the result of the object lock table shows how many objects are locked.

``` text
Object lock Table:
    Current number of objects which are locked = 2001
```

**coradb lockdb** outputs the OID, object type and table name of each object that obtained lock. In addition, it outputs the number of transactions that hold lock for the object (*Num holders*), the number of transactions (*Num blocked-holders*) that hold lock but are blocked since it could not convert the lock to the upper lock (e.g., conversion from **SCH_S_LOCK** to **SCH_M_LOCK**), and the number of different transactions that are waiting for the lock of the object (*Num waiters*). It also outputs the list of client transactions that hold lock, blocked client transactions and waiting client transactions. For rows, but not class, MVCC information is also shown.

The example below shows an object in which the object type is a class, that will be blocked because the class OID( 0\| 62\| 5 ) that has **IX_LOCK** for transaction 1 and **SCH_S_LOCK** for transaction 2 cannot be converted into **SCH_M_LOCK**. It also shows that transaction 3 is blocked because transaction 2 is waiting for **SCH_M_LOCK** even when transaction 3 is only waiting for **SCH_S_LOCK**.

``` text
OID = 0| 62| 5
Object type: Class = athlete.
Num holders = 1, Num blocked-holders= 1, Num waiters = 1
LOCK HOLDERS
    Tran_index = 1, Granted_mode = IX_LOCK, Count = 1, Nsubgranules = 1
BLOCKED LOCK HOLDERS
    Tran_index = 2, Granted_mode = SCH_S_LOCK, Count = 1, Nsubgranules = 0
    Blocked_mode = SCH_M_LOCK
                    Start_waiting_at = Wed Feb 3 14:44:31 2016
                    Wait_for_secs = -1
LOCK WAITERS
    Tran_index = 3, Blocked_mode = SCH_S_LOCK
                    Start_waiting_at = Wed Feb 3 14:45:14 2016
                    Wait_for_secs = -1
```

The next example shows an instance of class, object OID( 2\| 50\| 1 ), that was inserted by transaction 1 which holds **X_LOCK** on the object. The class has a unique index and the key of inserted instance is about to be modified by transaction 2, which is blocked until transaction 1 is completed.

``` text
OID = 2| 50| 1
Object type: instance of class ( 0| 62| 5) = athlete.
MVCC info: insert ID = 6, delete ID = missing.
Num holders = 1, Num blocked-holders= 1, Num waiters = 1
LOCK HOLDERS
    Tran_index =   1, Granted_mode =   X_LOCK, Count =   1
LOCK WAITERS
    Tran_index =   2, Blocked_mode = X_LOCK
                      Start_waiting_at = Wed Feb 3 14:45:14 2016
                      Wait_for_secs = -1
```

*Granted_mode* refers to the mode of the obtained lock, and *Blocked_mode* refers to the mode of the blocked lock. *Starting_waiting_at refers* to the time at which the lock was requested, and *Wait_for_secs* refers to the waiting time of the lock. The value of *Wait_for_secs* is determined by **lock_timeout**, a system parameter.

When the object type is a class (table), *Nsubgranules* is displayed, which is the sum of the record locks and the key locks obtained by a specific transaction in the table.

``` text
OID = 0| 62| 5
Object type: Class = athlete.
Num holders = 2, Num blocked-holders= 0, Num waiters= 0
LOCK HOLDERS:
Tran_index = 3, Granted_mode = IX_LOCK, Count = 2, Nsubgranules = 0
Tran_index = 1, Granted_mode = IX_LOCK, Count = 3, Nsubgranules = 1
Tran_index = 2, Granted_mode = IX_LOCK, Count = 2, Nsubgranules = 1
```


## tranlist

The **coradb tranlist** is used to check the transaction information of the target database.

``` bash
coradb tranlist [options] database_name
```

If you omit the \[options\], it displays the total information about each transaction.

"coradb tranlist testdb" outputs the similar result with "coradb killtran -q testdb", but tranlist outputs more items; "User name" and "Host name". "coradb tranlist -s testdb" outputs the same result with "coradb killtran -d testdb".

The following shows what information is displayed when you run "coradb tranlist testdb".

``` bash
$ coradb tranlist testdb

Tran index          User name      Host name      Process id    Program name              Query time    Tran time       Wait for lock holder      SQL_ID       SQL Text
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1(ACTIVE)           public     test-server           1681    broker1_cora_cas_1               0.00         0.00                       -1     *** empty ***  
   2(ACTIVE)           public     test-server           1682    broker1_cora_cas_2               0.00         0.00                       -1     *** empty ***  
   3(ACTIVE)           public     test-server           1683    broker1_cora_cas_3               0.00         0.00                       -1     *** empty ***  
   4(ACTIVE)           public     test-server           1684    broker1_cora_cas_4               1.80         1.80                  3, 2, 1     e5899a1b76253   update ta set a = 5 where a > 0
   5(ACTIVE)           public     test-server           1685    broker1_cora_cas_5               0.00         0.00                       -1     *** empty ***  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

SQL_ID: e5899a1b76253
Tran index : 4
update ta set a = 5 where a > 0
```

In the above example, when each three transaction is running INSERT statement, UPDATE statement is tried to run in the other transaction. In the above, UPDATE statement with "Tran index" 4 waits for the transactions 3,2,1, which are found in "Wait for lock holder", to be ended.

"SQL Text" is SQLs which are stored into the query plan cache; this is printed out as **empty** when this query's execution is terminated.

Each column's meaning is as following.

> - Tran index : the index of transaction
> - User name: database user's name
> - Host name: host name of CAS which running this transaction
> - Process id : client's process id
> - Program name : program name of a client
> - Query time : total execution time for the running query (unit: second)
> - Tran time : total run time for the current transaction (unit: second)
> - Wait for lock holder : the list of transactions which own the lock when the current transaction is waiting for a lock
> - SQL_ID: an ID for SQL Text
> - SQL Text : running SQL text (maximum 30 characters)

Transaction status messages, which are shown on "Tran index", are as follows.

> - ACTIVE : active state
> - RECOVERY : recovering transaction
> - COMMITTED : transaction which is already committed and will be ended soon.
> - COMMITTING : transaction which is committing
> - ABORTED : transaction which is rolled back and will be ended soon.
> - KILLED : transaction which is forcefully killed by the server.

The following shows \[options\] available with the **coradb tranlist** utility.

**-s, --summary**

This option outputs only summarized information(it omits query execution information or locking information).

``` bash
$ coradb tranlist -s testdb

Tran index          User name      Host name      Process id      Program name
-------------------------------------------------------------------------------
   1(ACTIVE)           public     test-server           1681 broker1_cora_cas_1
   2(ACTIVE)           public     test-server           1682 broker1_cora_cas_2
   3(ACTIVE)           public     test-server           1683 broker1_cora_cas_3
   4(ACTIVE)           public     test-server           1684 broker1_cora_cas_4
   5(ACTIVE)           public     test-server           1685 broker1_cora_cas_5
-------------------------------------------------------------------------------
```

**--sort-key=NUMBER**

This option outputs the ascending values sorted by the NUMBERth column. If the type of the column is the number, it is sorted by the number; if not, it is sorted by the string. If this option is omitted, the output is sorted by "Tran index".

The following is an example which outputs the sorted information by specifying the "Process id", the 4th column.

``` bash
$ coradb tranlist --sort-key=4 testdb

Tran index          User name      Host name      Process id    Program name              Query time    Tran time       Wait for lock holder      SQL_ID       SQL Text
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1(ACTIVE)           public     test-server           1681    broker1_cora_cas_1               0.00         0.00                       -1     *** empty ***
   2(ACTIVE)           public     test-server           1682    broker1_cora_cas_2               0.00         0.00                       -1     *** empty ***
   3(ACTIVE)           public     test-server           1683    broker1_cora_cas_3               0.00         0.00                       -1     *** empty ***
   4(ACTIVE)           public     test-server           1684    broker1_cora_cas_4               1.80         1.80                  3, 1, 2     e5899a1b76253   update ta set a = 5 where a > 0
   5(ACTIVE)           public     test-server           1685    broker1_cora_cas_5               0.00         0.00                       -1     *** empty ***
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

SQL_ID: e5899a1b76253
Tran index : 4
update ta set a = 5 where a > 0
```

**--reverse**

This option outputs the reversely sorted values.

The following is an example which outputs the reversely sorted values by the "Tran index".

``` text
Tran index          User name      Host name      Process id    Program name              Query time    Tran time     Wait for lock holder      SQL_ID       SQL Text
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   5(ACTIVE)           public     test-server           1685    broker1_cora_cas_5               0.00         0.00                     -1     *** empty ***
   4(ACTIVE)           public     test-server           1684    broker1_cora_cas_4               1.80         1.80                3, 2, 1     e5899a1b76253   update ta set a = 5 where a > 0
   3(ACTIVE)           public     test-server           1683    broker1_cora_cas_3               0.00         0.00                     -1     *** empty ***
   2(ACTIVE)           public     test-server           1682    broker1_cora_cas_2               0.00         0.00                     -1     *** empty ***
   1(ACTIVE)           public     test-server           1681    broker1_cora_cas_1               0.00         0.00                     -1     *** empty ***
------------------------------------------------------------------------------------------------------------------------------------------------------------------------

SQL_ID: e5899a1b76253
Tran index : 4
update ta set a = 5 where a > 0
```


## killtran

The **coradb killtran** is used to check transactions or abort specific transaction. Only a **DBA** can use options for killing a transaction.

``` bash
coradb killtran [options] database_name
```

- **coradb**: An integrated utility for the CoraDB service and database management
- **killtran**: A utility that manages transactions for a specified database
- *database_name*: The name of database whose transactions are to be killed

Some \[options\] refer to killing specified transactions; others refer to print active transactions. If no option is specified, **-d** is specified by default so all transactions are displayed on the screen.

``` bash
coradb killtran testdb 

Tran index      User name   Host name      Process id      Program name
-------------------------------------------------------------------------------
   1(ACTIVE)          dba      myhost             664           cora_cas
   2(ACTIVE)          dba      myhost            6700              corasql
   3(ACTIVE)          dba      myhost            2188           cora_cas
   4(ACTIVE)          dba      myhost             696              corasql
   5(ACTIVE)       public      myhost            6944              corasql
-------------------------------------------------------------------------------
```

The following shows \[options\] available with the **coradb killtran** utility.

**-i, --kill-transaction-index=ID1,ID2,ID3**

This option kills transactions in a specified index. Several transaction indexes can be specified by separating with comma(,). If there is an invalid transaction ID among several IDs, it is ignored.

``` bash
$ coradb killtran -i 1 testdb
Ready to kill the following transactions:

Tran index          User name      Host name      Process id      Program name
-------------------------------------------------------------------------------
   1(ACTIVE)              DBA         myhost           15771              corasql
   2(ACTIVE)              DBA         myhost            2171              corasql
-------------------------------------------------------------------------------
Do you wish to proceed ? (Y/N)y
Killing transaction associated with transaction index 1
Killing transaction associated with transaction index 2
```

**--kill-user-name=ID**

This option kills transactions for a specified OS user ID.

``` bash
coradb killtran --kill-user-name=os_user_id testdb
```

**--kill-host-name=HOST**

This option kills transactions of a specified client host.

``` bash
coradb killtran --kill-host-name=myhost testdb
```

**--kill-program-name=NAME**

This option kills transactions for a specified program.

``` bash
coradb killtran --kill-program-name=cora_cas testdb
```

**--kill-sql-id=SQL_ID**

This option kills transactions for a specified SQL ID.

``` bash
coradb killtran --kill-sql-id=5377225ebc75a testdb
```

**-p, --dba-password=PASSWORD**

The password of the **DBA** user. It can only be used together with **-i** or a **--kill-…** option; without it, killtran prompts for the password.

**-q, --query-exec-info**

The difference with the output of "coradb tranlist" command is that there are no "User name" column and "Host name" column. See [tranlist](https://www.coradb.ai/manual/admin/admin_transactions.html#tranlist).

**-d, --display-information**

This is the default option and it displays the summary of transactions. Its output is the same as the output of "coradb tranlist" with **-s** option. See `tranlist -s`

**-f, --force**

This option omits a prompt to check transactions to be stopped.

``` bash
coradb killtran -f -i 1 testdb
```
