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
- N_RSEGS =
128
- 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.
- #each_region {|{ :offset => pos_trx_sys_header, :length => size_trx_sys_header, :name => :trx_sys_header, :info => "Transaction System Header", }| ... } ⇒ Object
- #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_rsegs_array ⇒ Object
-
#pos_trx_sys_header ⇒ Object
The TRX_SYS header immediately follows the FIL header.
- #rsegs ⇒ Object
- #rsegs_array(cursor) ⇒ Object
- #size_doublewrite_info ⇒ Object
- #size_mysql_log_info ⇒ Object
- #size_trx_sys_header ⇒ 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, #fil_header, handle, #initialize, #inspect, #lsn, maybe_undefined, #name, #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
152 |
# File 'lib/innodb/page/trx_sys.rb', line 152 def binary_log; trx_sys[:binary_log]; end |
#doublewrite ⇒ Object
154 |
# File 'lib/innodb/page/trx_sys.rb', line 154 def doublewrite; trx_sys[:doublewrite]; end |
#doublewrite_info(cursor) ⇒ Object
Read the overall doublewrite buffer structures
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/innodb/page/trx_sys.rb', line 110 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.
95 96 97 98 99 100 101 102 103 |
# File 'lib/innodb/page/trx_sys.rb', line 95 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.
206 207 208 209 210 211 212 |
# File 'lib/innodb/page/trx_sys.rb', line 206 def dump super puts "trx_sys:" pp trx_sys puts end |
#each_region {|{ :offset => pos_trx_sys_header, :length => size_trx_sys_header, :name => :trx_sys_header, :info => "Transaction System Header", }| ... } ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/innodb/page/trx_sys.rb', line 156 def each_region unless block_given? return enum_for(:each_region) end super do |region| yield region end yield({ :offset => pos_trx_sys_header, :length => size_trx_sys_header, :name => :trx_sys_header, :info => "Transaction System Header", }) rsegs.each do |rseg| yield({ :offset => rseg[:offset], :length => 4 + 4, :name => :rseg, :info => "Rollback Segment", }) end yield({ :offset => pos_mysql_binary_log_info, :length => size_mysql_log_info, :name => :mysql_binary_log_info, :info => "Binary Log Info", }) yield({ :offset => pos_mysql_master_log_info, :length => size_mysql_log_info, :name => :mysql_master_log_info, :info => "Master Log Info", }) yield({ :offset => pos_doublewrite_info, :length => size_doublewrite_info, :name => :doublewrite_info, :info => "Double Write Buffer Info", }) nil end |
#fseg ⇒ Object
150 |
# File 'lib/innodb/page/trx_sys.rb', line 150 def fseg; trx_sys[:fseg]; end |
#master_log ⇒ Object
153 |
# File 'lib/innodb/page/trx_sys.rb', line 153 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.
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/innodb/page/trx_sys.rb', line 79 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.
44 45 46 |
# File 'lib/innodb/page/trx_sys.rb', line 44 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.
38 39 40 |
# File 'lib/innodb/page/trx_sys.rb', line 38 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.
32 33 34 |
# File 'lib/innodb/page/trx_sys.rb', line 32 def pos_mysql_master_log_info size - 2000 end |
#pos_rsegs_array ⇒ Object
22 23 24 |
# File 'lib/innodb/page/trx_sys.rb', line 22 def pos_rsegs_array pos_trx_sys_header + size_trx_sys_header end |
#pos_trx_sys_header ⇒ Object
The TRX_SYS header immediately follows the FIL header.
14 15 16 |
# File 'lib/innodb/page/trx_sys.rb', line 14 def pos_trx_sys_header pos_fil_header + size_fil_header end |
#rsegs ⇒ Object
151 |
# File 'lib/innodb/page/trx_sys.rb', line 151 def rsegs; trx_sys[:rsegs]; end |
#rsegs_array(cursor) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/innodb/page/trx_sys.rb', line 58 def rsegs_array(cursor) @rsegs_array ||= (0...N_RSEGS).to_a.inject([]) do |a, n| cursor.name("slot[#{n}]") do |c| slot = { :offset => c.position, :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 |
#size_doublewrite_info ⇒ Object
48 49 50 |
# File 'lib/innodb/page/trx_sys.rb', line 48 def size_doublewrite_info Innodb::FsegEntry::SIZE + (2 * (4 + 4 + 4)) + 4 end |
#size_mysql_log_info ⇒ Object
26 27 28 |
# File 'lib/innodb/page/trx_sys.rb', line 26 def size_mysql_log_info 4 + 8 + 100 end |
#size_trx_sys_header ⇒ Object
18 19 20 |
# File 'lib/innodb/page/trx_sys.rb', line 18 def size_trx_sys_header 8 + Innodb::FsegEntry::SIZE end |
#trx_id ⇒ Object
149 |
# File 'lib/innodb/page/trx_sys.rb', line 149 def trx_id; trx_sys[:trx_id]; end |
#trx_sys ⇒ Object
Read the TRX_SYS headers and other information.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/innodb/page/trx_sys.rb', line 128 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 |