Class: Innodb::Page::TrxSys
- Inherits:
-
Innodb::Page
- Object
- Innodb::Page
- Innodb::Page::TrxSys
- Defined in:
- lib/innodb/page/trx_sys.rb
Overview
A specialized class for TRX_SYS pages, which contain various information about the transaction system within InnoDB. Only one TRX_SYS page exists in any given InnoDB installation, and it is page 5 of the system tablespace (space 0), most commonly named “ibdata1”.
The basic structure of a TRX_SYS page is: FIL header, TRX_SYS header, empty space, master binary log information, empty space, local binary log information, empty space, doublewrite information (repeated twice), empty space, and FIL trailer.
Constant Summary collapse
- MYSQL_LOG_MAGIC_N =
A magic number present in each MySQL binary log information structure, which helps identify whether the structure is populated or not.
873422344
- DOUBLEWRITE_MAGIC_N =
A magic number present in each doublewrite buffer information structure, which helps identify whether the structure is populated or not.
536853855
- DOUBLEWRITE_SPACE_ID_STORED_MAGIC_N =
A magic number present in the overall doublewrite buffer structure, which identifies whether the space id is stored.
1783657386
Constants inherited from Innodb::Page
PAGE_TYPE, PAGE_TYPE_BY_VALUE, SPECIALIZED_CLASSES
Instance Attribute Summary
Attributes inherited from Innodb::Page
Instance Method Summary collapse
- #binary_log ⇒ Object
- #doublewrite ⇒ Object
-
#doublewrite_info(cursor) ⇒ Object
Read the overall doublewrite buffer structures.
-
#doublewrite_page_info(cursor) ⇒ Object
Read a single doublewrite buffer information structure from a given cursor.
-
#dump ⇒ Object
Dump the contents of a page for debugging purposes.
- #fseg ⇒ Object
- #master_log ⇒ Object
-
#mysql_log_info(cursor, offset) ⇒ Object
Read a MySQL binary log information structure from a given position.
-
#pos_doublewrite_info ⇒ Object
The doublewrite buffer information is located 200 bytes from the end of the page.
-
#pos_mysql_binary_log_info ⇒ Object
The local binary log information is located 1000 bytes from the end of the page.
-
#pos_mysql_master_log_info ⇒ Object
The master’s binary log information is located 2000 bytes from the end of the page.
-
#pos_trx_sys_header ⇒ Object
The TRX_SYS header immediately follows the FIL header.
- #rsegs ⇒ Object
- #rsegs_array(cursor) ⇒ Object
- #trx_id ⇒ Object
-
#trx_sys ⇒ Object
Read the TRX_SYS headers and other information.
Methods inherited from Innodb::Page
#calculate_checksum, #checksum, #corrupt?, #cursor, #data, #fil_header, handle, #initialize, #inspect, #lsn, maybe_undefined, #next, #offset, parse, #pos_fil_header, #pos_fil_trailer, #pos_page_body, #prev, #size, #size_fil_header, #size_fil_trailer, #type
Constructor Details
This class inherits a constructor from Innodb::Page
Instance Method Details
#binary_log ⇒ Object
132 |
# File 'lib/innodb/page/trx_sys.rb', line 132 def binary_log; trx_sys[:binary_log]; end |
#doublewrite ⇒ Object
134 |
# File 'lib/innodb/page/trx_sys.rb', line 134 def doublewrite; trx_sys[:doublewrite]; end |
#doublewrite_info(cursor) ⇒ Object
Read the overall doublewrite buffer structures
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/innodb/page/trx_sys.rb', line 90 def doublewrite_info(cursor) cursor.peek(pos_doublewrite_info) do |c_doublewrite| c_doublewrite.name("doublewrite") do |c| { :fseg => c.name("fseg") { Innodb::FsegEntry.get_inode(@space, c) }, :page_info => [ c.name("group[0]") { doublewrite_page_info(c) }, c.name("group[1]") { doublewrite_page_info(c) }, ], :space_id_stored => (c.name("space_id_stored") { c.get_uint32 } == DOUBLEWRITE_SPACE_ID_STORED_MAGIC_N), } end end end |
#doublewrite_page_info(cursor) ⇒ Object
Read a single doublewrite buffer information structure from a given cursor.
75 76 77 78 79 80 81 82 83 |
# File 'lib/innodb/page/trx_sys.rb', line 75 def doublewrite_page_info(cursor) { :magic_n => cursor.name("magic_n") { cursor.get_uint32 }, :page_number => [ cursor.name("page[0]") { cursor.get_uint32 }, cursor.name("page[1]") { cursor.get_uint32 }, ], } end |
#dump ⇒ Object
Dump the contents of a page for debugging purposes.
137 138 139 140 141 142 143 |
# File 'lib/innodb/page/trx_sys.rb', line 137 def dump super puts "trx_sys:" pp trx_sys puts end |
#fseg ⇒ Object
130 |
# File 'lib/innodb/page/trx_sys.rb', line 130 def fseg; trx_sys[:fseg]; end |
#master_log ⇒ Object
133 |
# File 'lib/innodb/page/trx_sys.rb', line 133 def master_log; trx_sys[:master_log]; end |
#mysql_log_info(cursor, offset) ⇒ Object
Read a MySQL binary log information structure from a given position.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/innodb/page/trx_sys.rb', line 59 def mysql_log_info(cursor, offset) cursor.peek(offset) do |c| if c.name("magic_n") { c.get_uint32 } == MYSQL_LOG_MAGIC_N { :offset => c.name("offset") { c.get_uint64 }, :name => c.name("name") { c.get_bytes(100) }, } end end end |
#pos_doublewrite_info ⇒ Object
The doublewrite buffer information is located 200 bytes from the end of the page.
31 32 33 |
# File 'lib/innodb/page/trx_sys.rb', line 31 def pos_doublewrite_info size - 200 end |
#pos_mysql_binary_log_info ⇒ Object
The local binary log information is located 1000 bytes from the end of the page.
25 26 27 |
# File 'lib/innodb/page/trx_sys.rb', line 25 def pos_mysql_binary_log_info size - 1000 end |
#pos_mysql_master_log_info ⇒ Object
The master’s binary log information is located 2000 bytes from the end of the page.
19 20 21 |
# File 'lib/innodb/page/trx_sys.rb', line 19 def pos_mysql_master_log_info size - 2000 end |
#pos_trx_sys_header ⇒ Object
The TRX_SYS header immediately follows the FIL header.
13 14 15 |
# File 'lib/innodb/page/trx_sys.rb', line 13 def pos_trx_sys_header pos_fil_header + size_fil_header end |
#rsegs ⇒ Object
131 |
# File 'lib/innodb/page/trx_sys.rb', line 131 def rsegs; trx_sys[:rsegs]; end |
#rsegs_array(cursor) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/innodb/page/trx_sys.rb', line 39 def rsegs_array(cursor) @rsegs_array ||= (0...256).to_a.inject([]) do |a, n| cursor.name("slot[#{n}]") do |c| slot = { :space_id => c.name("space_id") { Innodb::Page.maybe_undefined(c.get_uint32) }, :page_number => c.name("page_number") { Innodb::Page.maybe_undefined(c.get_uint32) }, } if slot[:space_id] && slot[:page_number] a << slot end end a end end |
#trx_id ⇒ Object
129 |
# File 'lib/innodb/page/trx_sys.rb', line 129 def trx_id; trx_sys[:trx_id]; end |
#trx_sys ⇒ Object
Read the TRX_SYS headers and other information.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/innodb/page/trx_sys.rb', line 108 def trx_sys @trx_sys ||= cursor(pos_trx_sys_header).name("trx_sys") do |c| { :trx_id => c.name("trx_id") { c.get_uint64 }, :fseg => c.name("fseg") { Innodb::FsegEntry.get_inode(@space, c) }, :rsegs => c.name("rsegs") { rsegs_array(c) }, :binary_log => c.name("binary_log") { mysql_log_info(c, pos_mysql_binary_log_info) }, :master_log => c.name("master_log") { mysql_log_info(c, pos_mysql_master_log_info) }, :doublewrite => doublewrite_info(c), } end end |