Locks, Latches, Claims, & Drains Flashcards

1
Q

Is locking more complicated in a Data Sharing Environment?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Locking exists to ensure what?

A

Data Integrity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does A.C.I.D stand for & what do each mean?

A

Atomic - “All or Nothing” for UOW
Consistent - Database consistent after Commit
Isolation - Concurrent transactions not inter-dependent
Durable - Updates persistent once committed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How much does memory cost in a non Data Sharing Env.?

A

Around 500-600 bytes of memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Regarding locks what is ideal?

A

Hold the lowest number of small locks for the least time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does IRLM stand for?

A

Internal Resource Lock Manager

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the IRLM address space naming format?

A

ssidIRLM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Where are the locks held in a data sharing environment?

A

Coupling Facility

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Theoretical limit for a single DB2 subsystem?

A

Around 100m locks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A typical 2GB IRLM hold just over how many locks?

A

3 million locks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the 4 essential locking concepts?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the Locking Hierarchy for Simple & Segmented?

A

Row/Page -> Table (Segmented Only) -> Tablespace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the Locking Hierarchy for Partitioned & UTS?

A

Row/Page -> Partition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is LOCKMAX?

A

The maximum number of locks per user to acquire for the TB or TS before escalating to the next locking level.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is NUMLKTS?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the 3 Locks Modes for Page & Row Level?

A

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

17
Q

What is an Intent Lock?

A

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.

18
Q

Where can I find the maximum wait time for a lock?

A

DSNZPARM IRLMRWT - Default is 30 seconds - CS is 10 (which means 10 seconds)

19
Q

What is the actual maximum time a lock could wait (for non data sharing environments) ?

A

IRLMRWT + Deadlock detection time

20
Q

What is a deadlock?

A

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.

21
Q

What is the Deadlock Detection Cycle DSNZPARM?

A

DEADLOCK - Default is 1 second

22
Q

What is the Deadlock Detection Cycle DSNZPARM?

A

DEADLOCK - Default is 1 second

23
Q

What is the one scenario at which DB2 will choose to abort if there is a deadlock?

A

If one of the objects is NOT LOGGED DB2 will choose the other so it doesn’t end up in a recovery situation.

24
Q

What are 3 ways to avoid Deadlocks?

A

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

25
Q

How are Locks Controlled for lower level locks (Page & Row) in App?

A

Controlled by SQL COMMIT

26
Q

RELEASE(COMMIT) releases what kind of locks at COMMIT?

A

Releases TS, TB, & Partition locks
- Except those needed to maintain Cursor position if WITH HOLD used . – In this case gross locks may be downgraded back to Intent Locks – For Ex. if Lock Escalation has occurred.

27
Q

RELEASE(DEALLOCATE) ?

A

Releases resources when thread terminates & cheaper but naturally holds locks for longer

28
Q

What does PKGREL_COMMIT do if package is set to RELEASE(DEALLOCATE) ?

A
  1. At COMMIT DB2 checks for waiters on the Package lock. 2. If any exist temporarily switches Package to RELEASE(COMMIT) 3. Allows (RE)REBIND, DDL, or REORG to proceed. 4. Restrictions involved but detailed discussion is out of scope. (CS = YES)
29
Q

What are the two aspects of Isolation?

A
  1. What you do if you encounter locks taken by another UOW

2. What others can do to data you’ve read but not updated.

30
Q

What are the 4 Isolation Options?

A
  1. RR - Repeatable Read
  2. RS - Read Stability
  3. CS - Cursor Stability
  4. UR - Uncommitted Read (also NC - No Commit)
31
Q

What is RR?

A

You can only read fully committed updates.
All your locks are retained until COMMIT
DB2 locks anything it touches including any non-qualifying rows
Re-reading Cursor within a UOW guaranteed to return identical results

32
Q

What is RS?

A

Similar to RR but locks are only held on qualifying rows.
Others can read and update non-qualifying rows as well as INSERT data
Re-reading Cursor will get at least the same data but potentially more

33
Q

What is CS?

A

You can only read fully committed updates. – Any data you read will be both consistent and persistent
Your non-exclusive locks are only held while CURRENT OF Cursor – Released when you Fetch the next row (depends on CURRENTDATA)
X-Locks are retained until COMMIT
If you re-read the same row twice within a UOW it may have changed

34
Q

What is UR?

A

You can read any data, even if locked, as well as uncommitted Updates. – Data could be inconsistent and not persistent.
You take no Read locks so others can read and update same data.
Isolation CS used for any Updates to ensure data integrity
Important to note UR does NOT mean no locking. – Claims are still used, along with Update, XML and LOB locks!

35
Q

What is a fuzzy read?

A

Fuzzy or non-repeatable reads: Fuzzy reads occur when a database transaction re-reads data it has already read and then finds that another committed transaction has modified or deleted the same data.

36
Q

What does CURRENTDATA only relate to?

A

ISOLATION(CS)

37
Q

What is CURRENTDATA?

A

Determines locking for Read Only or Ambiguous Cursors
Yes = Retains Locks
No = Releases locks as normal
If Yes, It will not release locks with CS (when cursor is done with the row)

38
Q

What is recommended for CURRENTDATA? Yes or No?

A

NO

39
Q

Does DB2 lock Indexes?

A

No, locks are only taken on underlying data pages or rows.