Class: Innodb::Page::TrxSys
- Inherits:
-
Innodb::Page
- Object
- Innodb::Page
- Innodb::Page::TrxSys
- Extended by:
- Forwardable
- Defined in:
- lib/innodb/page/trx_sys.rb
Defined Under Namespace
Classes: DoublewriteInfo, DoublewritePageInfo, Header, MysqlLogInfo, RsegSlot
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.
873_422_344
- DOUBLEWRITE_MAGIC_N =
A magic number present in each doublewrite buffer information structure, which helps identify whether the structure is populated or not.
536_853_855
- DOUBLEWRITE_SPACE_ID_STORED_MAGIC_N =
A magic number present in the overall doublewrite buffer structure, which identifies whether the space id is stored.
1_783_657_386
- N_RSEGS =
128
Constants inherited from Innodb::Page
PAGE_TYPE, PAGE_TYPE_BY_VALUE, UNDEFINED_PAGE_NUMBER
Instance Attribute Summary
Attributes inherited from Innodb::Page
Instance Method Summary collapse
-
#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 {|Region.new( offset: pos_trx_sys_header, length: size_trx_sys_header, name: :trx_sys_header, info: "Transaction System Header" )| ... } ⇒ 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_array(cursor) ⇒ Object
- #size_doublewrite_info ⇒ Object
- #size_mysql_log_info ⇒ Object
- #size_trx_sys_header ⇒ Object
-
#trx_sys ⇒ Object
Read the TRX_SYS headers and other information.
Methods inherited from Innodb::Page
#checksum_crc32, #checksum_crc32?, #checksum_innodb, #checksum_innodb?, #checksum_invalid?, #checksum_type, #checksum_valid?, #corrupt?, #cursor, #default_page_size?, #each_page_body_byte_as_uint8, #each_page_header_byte_as_uint8, #extent_descriptor?, #fil_header, #fil_trailer, handle, #in_doublewrite_buffer?, #initialize, #inspect, #inspect_header_fields, maybe_undefined, #misplaced?, #misplaced_offset?, #misplaced_space?, #name, page_type_by_value, parse, #pos_fil_header, #pos_fil_trailer, #pos_page_body, #pos_partial_page_header, register_specialization, #size, #size_fil_header, #size_fil_trailer, #size_page_body, #size_partial_page_header, specialization_for, specialization_for?, #torn?, undefined?
Constructor Details
This class inherits a constructor from Innodb::Page
Instance Method Details
#doublewrite_info(cursor) ⇒ Object
Read the overall doublewrite buffer structures
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/innodb/page/trx_sys.rb', line 149 def doublewrite_info(cursor) cursor.peek(pos_doublewrite_info) do |c_doublewrite| c_doublewrite.name("doublewrite") do |c| DoublewriteInfo.new( fseg: c.name("fseg") { Innodb::FsegEntry.get_inode(@space, c) }, page_info: [0, 1].map { |n| c.name("group[#{n}]") { doublewrite_page_info(c) } }, space_id_stored: (c.name("space_id_stored") { c.read_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.
139 140 141 142 143 144 145 146 |
# File 'lib/innodb/page/trx_sys.rb', line 139 def doublewrite_page_info(cursor) magic_n = cursor.name("magic_n") { cursor.read_uint32 } DoublewritePageInfo.new( magic_n: magic_n, page_number: [0, 1].map { |n| cursor.name("page[#{n}]") { cursor.read_uint32 } } ) end |
#dump ⇒ Object
Dump the contents of a page for debugging purposes.
228 229 230 231 232 233 234 |
# File 'lib/innodb/page/trx_sys.rb', line 228 def dump super puts "trx_sys:" pp trx_sys puts end |
#each_region {|Region.new( offset: pos_trx_sys_header, length: size_trx_sys_header, name: :trx_sys_header, info: "Transaction System Header" )| ... } ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/innodb/page/trx_sys.rb', line 182 def each_region(&block) return enum_for(:each_region) unless block_given? super yield Region.new( offset: pos_trx_sys_header, length: size_trx_sys_header, name: :trx_sys_header, info: "Transaction System Header" ) rsegs.each do |rseg| yield Region.new( offset: rseg[:offset], length: 4 + 4, name: :rseg, info: "Rollback Segment" ) end yield Region.new( offset: pos_mysql_binary_log_info, length: size_mysql_log_info, name: :mysql_binary_log_info, info: "Binary Log Info" ) yield Region.new( offset: pos_mysql_master_log_info, length: size_mysql_log_info, name: :mysql_master_log_info, info: "Master Log Info" ) yield Region.new( offset: pos_doublewrite_info, length: size_doublewrite_info, name: :doublewrite_info, info: "Double Write Buffer Info" ) nil end |
#mysql_log_info(cursor, offset) ⇒ Object
Read a MySQL binary log information structure from a given position.
125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/innodb/page/trx_sys.rb', line 125 def mysql_log_info(cursor, offset) cursor.peek(offset) do |c| magic_n = c.name("magic_n") { c.read_uint32 } == MYSQL_LOG_MAGIC_N break unless magic_n MysqlLogInfo.new( magic_n: magic_n, offset: c.name("offset") { c.read_uint64 }, name: c.name("name") { c.read_bytes(100) } ) end end |
#pos_doublewrite_info ⇒ Object
The doublewrite buffer information is located 200 bytes from the end of the page.
89 90 91 |
# File 'lib/innodb/page/trx_sys.rb', line 89 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.
83 84 85 |
# File 'lib/innodb/page/trx_sys.rb', line 83 def pos_mysql_binary_log_info size - 1_000 end |
#pos_mysql_master_log_info ⇒ Object
The master’s binary log information is located 2000 bytes from the end of the page.
77 78 79 |
# File 'lib/innodb/page/trx_sys.rb', line 77 def pos_mysql_master_log_info size - 2_000 end |
#pos_rsegs_array ⇒ Object
67 68 69 |
# File 'lib/innodb/page/trx_sys.rb', line 67 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.
59 60 61 |
# File 'lib/innodb/page/trx_sys.rb', line 59 def pos_trx_sys_header pos_page_body end |
#rsegs_array(cursor) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/innodb/page/trx_sys.rb', line 111 def rsegs_array(cursor) @rsegs_array ||= N_RSEGS.times.each_with_object([]) do |n, a| cursor.name("slot[#{n}]") do |c| slot = RsegSlot.new( offset: c.position, space_id: c.name("space_id") { Innodb::Page.maybe_undefined(c.read_uint32) }, page_number: c.name("page_number") { Innodb::Page.maybe_undefined(c.read_uint32) } ) a << slot if slot.space_id && slot.page_number end end end |
#size_doublewrite_info ⇒ Object
93 94 95 |
# File 'lib/innodb/page/trx_sys.rb', line 93 def size_doublewrite_info Innodb::FsegEntry::SIZE + (2 * (4 + 4 + 4)) + 4 end |
#size_mysql_log_info ⇒ Object
71 72 73 |
# File 'lib/innodb/page/trx_sys.rb', line 71 def size_mysql_log_info 4 + 8 + 100 end |
#size_trx_sys_header ⇒ Object
63 64 65 |
# File 'lib/innodb/page/trx_sys.rb', line 63 def size_trx_sys_header 8 + Innodb::FsegEntry::SIZE end |
#trx_sys ⇒ Object
Read the TRX_SYS headers and other information.
162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/innodb/page/trx_sys.rb', line 162 def trx_sys @trx_sys ||= cursor(pos_trx_sys_header).name("trx_sys") do |c| Header.new( trx_id: c.name("trx_id") { c.read_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 |