understanding the lock manager with the fb lock print utility · understanding the lock manager...
Post on 25-Mar-2019
241 Views
Preview:
TRANSCRIPT
Understanding the lock manager
with the fb_lock_print utility
Dmitry Yemanov mailto:dimitr@firebirdsql.org
Firebird Project
http://www.firebirdsql.org/
Firebird Conference 2011, Luxembourg 2
Synchronization in Firebird
Internal vs external locks
●Mutexes, spinlocks, RW locks, latches
●Lock manager
Features of the global locks
●Multiple states (SR, PR, SW, PW, EX)
●Blocking notifications
●Deadlock detection
●Monitoring abilities
Firebird Conference 2011, Luxembourg 3
Lock Types and their Usage
Lock types
●Database lock
●Existence locks (table, procedure, index, collation)
●Table access locks
●Transaction locks
●Sweep, shadow, monitoring, etc locks
●Page locks (!)
Firebird Conference 2011, Luxembourg 4
Lock Types and their Usage
Lock types
LCK_database = 1 // Root of lock tree
LCK_relation = 2 // Individual relation
lock
LCK_bdb = 3 // Individual buffer
block
LCK_tra = 4 // Individual
transaction lock
LCK_rel_exist = 5 // Relation existence lock
LCK_idx_exist = 6 // Index existence lock
LCK_attachment = 7 // Attachment lock
...
Firebird Conference 2011, Luxembourg 5
Locks and Firebird Architectures
SuperServer
●No page locks
●Small lock table
●Fast LM operations
Classic and SuperClassic
●Page locks are widely used
●Large lock table
●LM operations may require IPC
Firebird Conference 2011, Luxembourg 6
Lock Manager in Classic
fb_inet_server fb_inet_server
fb_lock_mgr
Lock table (shmem)
IPC IPC
IPC
Connection 1
Connection 2
Firebird Conference 2011, Luxembourg 7
Inside the Lock Table
Block types
●Header section
●Lock owners
●Lock resources
●Lock requests
Internals
●Single mutex around the shmem region
●Remappings
●Hash table of lock keys
Firebird Conference 2011, Luxembourg 8
Inside the Lock Table
Lock resource
Series: page lock Key: 01:75 State: PR
Lock request 1 PR (granted)
Lock request 3 EX (pending)
Lock request 4 EX (pending)
Owner 1 PID = 1008
Owner 3 PID = 870
Owner 4 PID = 114
Lock request 2 PR (granted)
Owner 2 PID = 788
Firebird Conference 2011, Luxembourg 9
Inside the Lock Table
Owner states
●Waiting = 0x4
●Signaled = 0x10
Request states
●Pending = 0x2
●Blocking = 0x1
●Blocking seen = 0x100
Firebird Conference 2011, Luxembourg 10
Tuning the Lock Manager
Configuration options
●LockMemSize (1MB)
~= <cache pages> * <max connections> * 100
●LockSemCount (32) – deprecated in v2.5
●LockHashSlots (1009)
Other considerations
●FIREBIRD_LOCK envvar
Firebird Conference 2011, Luxembourg 11
Using the Lock Print Utility
Output control switches
●-o [wners]
●-l [ocks]
●-r [equests]
●-s [eries] <number>
●-a [ll]
●-w [ait list]
Default output
●Header and owners only
Firebird Conference 2011, Luxembourg 12
Using the Lock Print Utility
Interactive mode
●-i [aotw] <number> <number>
●Acquires, operations, types, waits
●Seconds and intervals
Other options
●-c
●-d <database> or -f <lock file>
●-m
Firebird Conference 2011, Luxembourg 13
Questions?
top related