G
George Potemkin
Guest
I have some questions about the latches and how Progress uses them. Here is just a few of these questions. I hope someone knows the answers. 1. What is the purpose of the SEQ latch? Progress stores the current values of the database sequences in the sequence block (bk_type 6, third block in Schema Area or mb_seqblk) as well as in the sequence control structures protected by the SEQ latch. At least broker reads the sequence block during a database startup. CURRENT-VALUE() function reads a sequence block using a shared buffer lock (DB Buf S Lock) and locks the SEQ latch. In other words, it reads the both sources of the sequence's current values. NEXT-VALUE() uses the exclusive buffer lock (DB Buf X Lock) and locks the SEQ latch twice. In other words, it updates the both sources. More over since V11 Progress additionally locks transaction end queue (TXQ) latch - twice in both cases. Sequence reads as well as sequence updates are not a part of transaction. Why these operations are additionally protected by TXQ latch? 2. What is the difference between the queue type latches (USR and SCH latches) and TXQ latch that protects the acquire/release of TXE resource locks (Share, Update & Commit)? In both cases the processes use the semaphores to wait for the database resources. In case of the queue type latches it's the semaphore latch waits reported by promon/R&D/2/13. Activity: Other. In case of TXQ latch it's the waits reported by promon/R&D/debghb/6/9. Activity: TXE Lock Activity. In both cases we can get the naps for the latches as well. Does it mean that Progress uses two locking mechanisms (one is a short term lock and another is a medium term lock) to access the same database resources? Sequentially? It does not have a meaning for me. In parallel? I can't get it either. 3. Process can lock a few latches at the same time. The most obvious example is the MTX latch. Unlike any other latches it does not protect any specific structures in shared memory. It protects transaction allocation and bi/ai recovery note /order/. MTX lock can be hold during disk IO but even if it's not the case the duration of the MTX latch locks is the longest among the latches. Process holds MTX latch while it loads other latch code into CPU cache and while other latch code is updating the correspondent structure in shared memory. Time needed to load a latch code seems to be of the same order as the execution time of this code. Hence if a process holds a latch and it needs to lock another latch then the lock duration of the first latch can significantly increase even if there is no contention on the second latch. I know that processes can simultaneously lock the LKT and LKF latches (Lock Table Hash Latch and Lock Table Free Chain Latch). I guess that a process locks LKT latch first and then it may need to lock LKF latch. This happens in 90% of the times in case of the self-service sessions. If it's true then why the LKT latch is multi-threaded (type 1 family) while LKF latch is a regular (plain) latch? LKF can't be multi-threaded by its nature. The different processes can simultaneously lock the different latches of the LKT family but they still should wait for the LKF latch. Hence the whole mechanism will work as single-threaded. What are the combination of latches (other than MTX+anything and LKT+LKF) can be locked by a process at the same time? I know that Progress uses a protocol based on the latch's masks. We can see these masks in promon/R&D/4/6. Restricted Options: 8j2hhs7gio Below is the table with the values converted to the hexadecimal and binary mode and sorted by mask but I don't know how Progress uses them. For example, two LRU latches - for primary and for alternate buffer pools - have totally different masks. Either promon reports the values that are not really used or there is something about LRU latch for alternate buffer pool that we do not yet know. Latch Mask/hex Mask/binary -- --- --------- --------------------------------- 0 L00 100000000 100000000000000000000000000000000 1 MTX 100000000 100000000000000000000000000000000 2 USR 100000000 100000000000000000000000000000000 3 OM 100000000 100000000000000000000000000000000 4 BIB 100000000 100000000000000000000000000000000 5 SCH 100000000 100000000000000000000000000000000 8 TXT 100000000 100000000000000000000000000000000 9 LKT 100000000 100000000000000000000000000000000 13 SEQ 100000000 100000000000000000000000000000000 15 TXQ 100000000 100000000000000000000000000000000 22 LRU 100000000 100000000000000000000000000000000 29 CDC 100000000 100000000000000000000000000000000 30 SEC 100000000 100000000000000000000000000000000 31 L31 100000000 100000000000000000000000000000000 28 INC F0000000 11110000000000000000000000000000 20 PWQ F03C0000 11110000001111000000000000000000 23 LRU F0C00000 11110000110000000000000000000000 19 BHT F0F80000 11110000111110000000000000000000 18 BFP F1000000 11110001000000000000000000000000 21 CPQ F1000000 11110001000000000000000000000000 24 BUF FF400000 11111111010000000000000000000000 25 BUF FF400000 11111111010000000000000000000000 26 BUF FF400000 11111111010000000000000000000000 27 BUF FF400000 11111111010000000000000000000000 7 GST FFF8A000 11111111111110001010000000000000 16 EC FFFFC000 11111111111111111100000000000000 6 LKP FFFFE200 11111111111111111110001000000000 17 LKF FFFFE200 11111111111111111110001000000000 12 LKT FFFFF200 11111111111111111111001000000000 11 LKT FFFFFA00 11111111111111111111101000000000 10 LKT FFFFFE00 11111111111111111111111000000000 14 AIB FFFFFF00 11111111111111111111111100000000
Continue reading...
Continue reading...