Locks, Latches, Claims, & Drains Flashcards
Is locking more complicated in a Data Sharing Environment?
Yes
Locking exists to ensure what?
Data Integrity
What does A.C.I.D stand for & what do each mean?
Atomic - “All or Nothing” for UOW
Consistent - Database consistent after Commit
Isolation - Concurrent transactions not inter-dependent
Durable - Updates persistent once committed
How much does memory cost in a non Data Sharing Env.?
Around 500-600 bytes of memory
Regarding locks what is ideal?
Hold the lowest number of small locks for the least time
What does IRLM stand for?
Internal Resource Lock Manager
What is the IRLM address space naming format?
ssidIRLM
Where are the locks held in a data sharing environment?
Coupling Facility
Theoretical limit for a single DB2 subsystem?
Around 100m locks
A typical 2GB IRLM hold just over how many locks?
3 million locks
What are the 4 essential locking concepts?
Scope - How much data is locked
Mode - What type of lock has been requested
Duration - how long the lock is held
Isolation - Describe the impact of UOW on each other & works both ways - a UOW can impact and/or ignore others
What is the Locking Hierarchy for Simple & Segmented?
Row/Page -> Table (Segmented Only) -> Tablespace
What is the Locking Hierarchy for Partitioned & UTS?
Row/Page -> Partition
What is LOCKMAX?
The maximum number of locks per user to acquire for the TB or TS before escalating to the next locking level.
What is NUMLKTS?
Is a subsystem parm that specifies the default maximum number of page, row, or LOB locks that an application can hold simultaneously in a table or table space. If a application exceeds the maximum number of locks in a single TB or TS, lock escalation occurs. (Across all objects)
What are the 3 Locks Modes for Page & Row Level?
S - (Shared) - Select, Fetch, Some Open Cursor
X - (Exclusive) - Any SQL that modifies data - Insert, Update, Delete, Merge
U - (Update) - Fetch for Update - Promoted to an X lock when the data is modified - Helps prevents deadlocks
What is an Intent Lock?
DB2 always places an Intent lock on all higher level objects in the locking hierarchy before using a lower level lock. — When a page or row is locked, the table, partition, or table space that contains it is also locked. This intent lock indicates the plan that the application process has for accessing the data.
Where can I find the maximum wait time for a lock?
DSNZPARM IRLMRWT - Default is 30 seconds - CS is 10 (which means 10 seconds)
What is the actual maximum time a lock could wait (for non data sharing environments) ?
IRLMRWT + Deadlock detection time
What is a deadlock?
A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting in both programs ceasing to function.
What is the Deadlock Detection Cycle DSNZPARM?
DEADLOCK - Default is 1 second
What is the Deadlock Detection Cycle DSNZPARM?
DEADLOCK - Default is 1 second
What is the one scenario at which DB2 will choose to abort if there is a deadlock?
If one of the objects is NOT LOGGED DB2 will choose the other so it doesn’t end up in a recovery situation.
What are 3 ways to avoid Deadlocks?
1 - Ensure you access objects in the same order
2 - Use FOR UPDATE clause when you know you’re going to Update
3 - Row locking can help but it causes increased locking