Understanding the lock manager with the fb_lock_print utility Dmitry Yemanov mailto:dimitr@firebirdsql.org Firebird Projec...
Synchronization in Firebird <ul><li>Internal vs external locks </li></ul><ul><ul><li>Mutexes, spinlocks, RW locks, latches
Lock manager </li></ul></ul><ul><li>Features of the global locks </li></ul><ul><ul><li>Multiple states (SR, PR, SW, PW, EX)
Blocking notifications
Deadlock detection
Monitoring abilities </li></ul></ul>
Lock Types and their Usage <ul><li>Lock types </li></ul><ul><ul><li>Database lock
Existence locks (table, procedure, index, collation)
Table access locks
Transaction locks
Sweep, shadow, monitoring, etc locks </li></ul></ul><ul><ul><li>Page locks (!) </li></ul></ul>
Lock Types and their Usage <ul><li>Lock types </li></ul>LCK_database = 1 // Root of lock tree LCK_relation = 2 // Individu...
Locks and Firebird Architectures <ul><li>SuperServer </li></ul><ul><ul><li>No page locks
Upcoming SlideShare
Loading in...5
×

Understanding the lock manager internals with the fb lock print utility

2,390

Published on

This session will provide a short introduction to the Firebird lock manager and its usage patterns. It will describe how the lock manager can affect the performance of highly loaded systems and outlines the possible bottlenecks and other problems like unexpected lock-ups/freezes that may require special analysis. The structure of the lock table will also be explained.
It will also include a detailed description of the fb_lock_print utility and its usage that will enable the research of issues that are related to the lock manager. A few practical examples illustrating how to analyze the utility output will be provided. This session is mainly of interest to Classic Server users and DBAs.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,390
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
31
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Understanding the lock manager internals with the fb lock print utility

  1. 1. Understanding the lock manager with the fb_lock_print utility Dmitry Yemanov mailto:dimitr@firebirdsql.org Firebird Project http://www.firebirdsql.org/
  2. 2. Synchronization in Firebird <ul><li>Internal vs external locks </li></ul><ul><ul><li>Mutexes, spinlocks, RW locks, latches
  3. 3. Lock manager </li></ul></ul><ul><li>Features of the global locks </li></ul><ul><ul><li>Multiple states (SR, PR, SW, PW, EX)
  4. 4. Blocking notifications
  5. 5. Deadlock detection
  6. 6. Monitoring abilities </li></ul></ul>
  7. 7. Lock Types and their Usage <ul><li>Lock types </li></ul><ul><ul><li>Database lock
  8. 8. Existence locks (table, procedure, index, collation)
  9. 9. Table access locks
  10. 10. Transaction locks
  11. 11. Sweep, shadow, monitoring, etc locks </li></ul></ul><ul><ul><li>Page locks (!) </li></ul></ul>
  12. 12. Lock Types and their Usage <ul><li>Lock types </li></ul>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 ...
  13. 13. Locks and Firebird Architectures <ul><li>SuperServer </li></ul><ul><ul><li>No page locks
  14. 14. Small lock table
  15. 15. Fast LM operations </li></ul></ul><ul><li>Classic and SuperClassic </li></ul><ul><ul><li>Page locks are widely used
  16. 16. Large lock table
  17. 17. LM operations may require IPC </li></ul></ul>
  18. 18. Lock Manager in Classic IPC IPC IPC Connection 1 Connection 2 fb_inet_server fb_inet_server fb_lock_mgr Lock table (shmem)
  19. 19. Inside the Lock Table <ul><li>Block types </li></ul><ul><ul><li>Header section
  20. 20. Lock owners
  21. 21. Lock resources
  22. 22. Lock requests </li></ul></ul><ul><li>Internals </li></ul><ul><ul><li>Single mutex around the shmem region
  23. 23. Remappings
  24. 24. Hash table of lock keys </li></ul></ul>
  25. 25. 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
  26. 26. Inside the Lock Table <ul><li>Owner states </li></ul><ul><ul><li>Waiting = 0x4
  27. 27. Signaled = 0x10 </li></ul></ul><ul><li>Request states </li></ul><ul><ul><li>Pending = 0x2
  28. 28. Blocking = 0x1
  29. 29. Blocking seen = 0x100 </li></ul></ul>
  30. 30. Tuning the Lock Manager <ul><li>Configuration options </li></ul><ul><ul><li>LockMemSize (1MB) ~= <cache pages> * <max connections> * 100
  31. 31. LockSemCount (32) – deprecated in v2.5
  32. 32. LockHashSlots (1009) </li></ul></ul><ul><li>Other considerations </li></ul><ul><ul><li>FIREBIRD_LOCK envvar </li></ul></ul>
  33. 33. Using the Lock Print Utility <ul><li>Output control switches </li></ul><ul><ul><li>-o [wners]
  34. 34. -l [ocks]
  35. 35. -r [equests]
  36. 36. -s [eries] <number>
  37. 37. -a [ll]
  38. 38. -w [ait list] </li></ul></ul><ul><li>Default output </li></ul><ul><ul><li>Header and owners only </li></ul></ul>
  39. 39. Using the Lock Print Utility <ul><li>Interactive mode </li></ul><ul><ul><li>-i [aotw] <number> <number>
  40. 40. Acquires, operations, types, waits
  41. 41. Seconds and intervals </li></ul></ul><ul><li>Other options </li></ul><ul><ul><li>-c
  42. 42. -d <database> or -f <lock file>
  43. 43. -m </li></ul></ul>
  44. 44. Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×