What is the difference between a lock and a latch in the context of concurrent access to a database?
I am trying to understand a paper on concurrent B-tree, in which the author mentioned latch vs lock, and how latches do not need a «Lock Manager». I have been trying to figure out what are differences between those two for two days. Google resulting in: «locks assure logical consistency of data. They are implemented via a lock table, held for a long time (e.g. 2PL), and part of the deadlock detection mechanism. latches are like semaphores. They assure physical consistency of data and resources, which are not visible at the transactional level» However, I am still pretty confused. Can some one elaborate on this? and what exactly does a lock manager do? Thanks in advance.
asked Jun 24, 2010 at 15:27
2,274 2 2 gold badges 19 19 silver badges 31 31 bronze badges
9 Answers 9
From CMU 15-721 (Spring 2016), lecture 6 presentation, slides 25 and 26, which cites A Survey of B-Tree Locking Techniques by Goetz Graefe:
Locks
→ Protects the index’s logical contents from other txns.
→ Held for txn duration.
→ Need to be able to rollback changes.
Latches
→ Protects the critical sections of the index’s internal data structure from other threads.
→ Held for operation duration.
→ Do not need to be able to rollback changes.

answered Feb 26, 2017 at 3:12
user454322 user454322
7,349 5 5 gold badges 42 42 silver badges 52 52 bronze badges
It really depends on your DBMS, but here’s a good explanation for Oracle.
Latches are like locks for RAM memory structures to prevent concurrent access and ensure serial execution of kernel code. The LRU (least recently used) latches are used when seeking, adding, or removing a buffer from the buffer cache, an action that can only be done by one process at a time.
answered Jun 24, 2010 at 15:29
Matt Rogish Matt Rogish
24.6k 11 11 gold badges 76 76 silver badges 92 92 bronze badges
Following is from SQL Server stand point.
Latches are short-term light weight synchronization objects. Unlike locks, latches do not hold till the entire logical transaction. They hold only on the operation on the page .
Latches are used by the engine for synchronization of multiple threads (for example trying to insert on a table). Latches are not for developer or application — it is for the engine to do it’s task. Latches are internal control mechanism. Whereas locks are for the developer and application to control. Latches are for internal memory consistency. Locks are for logical transactional consistency.
Waits caused by latches are very important for diagnosing performance issues. Take a look at Diagnosing and Resolving Latch Contention on SQL Server — Whitepaper. The PAGEIOLATCH_EX is an important wait type.
- SQL Server Latches and their indication of performance issues
- Knee-Jerk Wait Statistics : PAGELATCH
- Inside SQL Server: Indexing and Locking
Locking latching кнопка что означает
Sticky keys may be either latched or locked:
- You latch a modifier key by pressing it once. A latched key stays active until a non-modifier key is pressed. Suppose that, with StickyKeys on, you press the Control key. It will stay “pressed” while you press the l key, giving you Control-L. Once you press l, Control is “released.”
- You lock a modifier key by pressing it twice in succession. The key stays locked until you press it again. For example, suppose you want to enter
In this case, you would press Shift twice to lock it. Then you’d press the colon key and the letters w and r. To unlock Shift, press it again.
You can bring up a Status window to see which keys are latched or locked. (See Displaying the Status of Buttons and Keys.)
- Previous: Turning StickyKeys On and Off
- Next: StickyKeys Settings
What is difference between lock and latch lock in connectors?
What is difference between lock and latch lock in connectors? eg 87832-1420 is a mentioned as lock and DF51A-14DP-2DSA is mentioned a s latch lock Links: 87832-1420
DF51A-14DP-2DSA(01)
Also Detent Lock 620303124022
149k 18 18 gold badges 211 211 silver badges 389 389 bronze badges
asked Sep 24, 2021 at 9:22
543 3 3 silver badges 13 13 bronze badges
Sep 24, 2021 at 11:48
\$\begingroup\$ I don’t think these terms have a standard universal meaning. You just need to read the datasheets to find out what they mean. \$\endgroup\$
Sep 24, 2021 at 13:19
\$\begingroup\$ In this case «latch lock» means that you have to press the release mechanism on both sides to unplug it. But that term isn’t used in the manufacturer’s data sheet anywhere (they call it a «positive lock») so it’s just what someone else somewhere has chosen to call it. \$\endgroup\$
Sep 24, 2021 at 16:12
1 Answer 1
\$\begingroup\$
Well, for once thing, neither one is a lock. Lock is a mechanism that requires a key to release, and neither of these connector does. Indeed, very few connectors are truly locked: «powerlock» unipole connectors (a plastic key is needed to release before unmating) and some specialized circular connector for railway applications (they use a standard padlock).
To answer your question:
- The so-called «Detent lock» (or «passive-lock») is actually «detent fastening»: the mates snap into place; to unmate, you need to pull a little bit harder to get past the snap (no other action is required)
- The co-called «latch-lock» (or «active-lock») is actually «latch fastening»: the mates snap into place; to unmate, and you need to first release the latch (e.g., by pressing a lever) then pull. So, action is required.
TL;DR: the difference is that the latter requires user action before unmating.
answered Oct 10 at 20:11
Davide Andrea Davide Andrea
18.9k 5 5 gold badges 34 34 silver badges 69 69 bronze badges
- connector
- header
-
The Overflow Blog
sponsored post
Related
Hot Network Questions
Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.12.5.2076
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Locking latching Button for Machine ON / OFF
Hello guys,
i have ordered couple of buttons, some are momentary type button the others locking buttons. I want to have a physical locking button for Machine On/Off and later also for coolant if needed.
With the below code the machine goes on when pushing the button, but when i release it it stays on, i have to push the button again to power off the machine:
net btn-pwr toggle.0.in net pwr-btn toggle2nist.0.in net tog-on toggle2nist.0.is-on net pwr-on halui.machine.on net pwr-off halui.machine.off
I am not sure which commands i need to power off the machine when the button is released. On the Toggle2nist doc page i have read that the command is for a momentary button, so i am wondering if there is a command for a locking button?
Thanks in advance.
Please Log in or Create an account to join the conversation.
- Posts: 241
- Thank you received: 17