Platform Framework
R24 AMR | Min(s) read

TAFJ Database Lock Manager

This section explains the concept of TAFJ Database lock manager and the working of its two algorithms.

You need to edit the [project].properties file to enable the DATABASE lock manager as shown below.

temn.tafj.locking.mode	= DATABASE

The Database locking mode has two different algorithms:

  • Mode 1: It uses the TAFJ_NONEXISTING_ROWS table.
  • Mode 2: It uses the TAFJ HASHLOCKS table..

The default mode of Database lock manager is Mode 1 but you can switch the mode to Mode 2 by adding the below property in the properties file.

temn.tafj.jdbc.db.locking.insert.rows.on.demand = false

You need to execute the savepoint stored procedure inside the database from TAFJ_HOME/dbscripts/<DB flavour>/createSavePointStoredProc.sql for Temenos Transact service architecture support.

Mode 1

This mode makes use of an internal technical number table TAFJ_NONEXISTING_ROWS for handling the locks of non-existing records from the application. This table is created on fly in the runtime environment when the locking mode is set appropriately.

This mode handles the inserts and deletes in a technical table TAFJ_NONEXISTING_ROWS. This is performed on demand as a part of transaction boundary.

In cases when JVM aborts, you can use the clean up mechanism for application server. Here, you need to execute the CLEANUP.STALE.ENTRIES JBC routine, which is shipped with TAFJ in TAFJBasic.jar.

The cleanup mechanism for standalone TAFJ is not in place out of box, alternatively the above routine CLEAUP.STALE.ENTRIES should be executed from a shell prompt to perform the cleanup.

Mode 2

This mode makes use of an internal technical number table TAFJ_HASHLOCKS containing values ranging from 0 – 2147483647 (maximum integer value).

You can populate this table by running the TAFJ_HOME/dbscripts/<DB flavour>/tafj_hashlock_tab_prepare.sql script. The procedure runs for around 1 to 2 hours depending on the hardware of the database server.

For oracle database, the procedure needs to run in SYSDBA login as it involves creation of index, primary key, altering user data files and altering temp table spaces to accommodate the huge table inside the database.

READU without LOCKED Clause for a Non-Existent Record

In the screen below, you can see the second session is waiting on lock for the first one to commit or roll back.

Once the rollback from first session, the other session grabs the lock.

READU with LOCKED Clause for a Non-Existent Record

When both the sessions ask for a READU and LOCKED clause on a non-existent record, the first one acquiring the lock will end up in ELSE clause and the second thread enters LOCKED clause and continues.

Reporting locks with DBTools (with the LOCKS command) will appear a bit different when using this mode. When you issue the LOCKS command, only the blocking locks can be viewed under this mode.

Session A takes a lock on FBNK.CURRENCY CHF without a LOCKED clause and session B does the same. The session B hangs till it manages to obtain the lock to continue further. In this case, an entry in LOCKS command will show up as blocking lock along with the time in seconds is blocked.

Copyright © 2020- Temenos Headquarters SA

Published on :
Monday, May 27, 2024 5:03:33 PM IST