class Innodb::Page::TrxSys
Constants
- DOUBLEWRITE_MAGIC_N
A magic number present in each doublewrite buffer information structure, which helps identify whether the structure is populated or not.
- DOUBLEWRITE_SPACE_ID_STORED_MAGIC_N
A magic number present in the overall doublewrite buffer structure, which identifies whether the space id is stored.
- DoublewriteInfo
- DoublewritePageInfo
- Header
- 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.
- MysqlLogInfo
- N_RSEGS
- RsegSlot
Public Instance Methods
Read the overall doublewrite buffer structures
# 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
Read a single doublewrite buffer information structure from a given cursor.
# 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 the contents of a page for debugging purposes.
Innodb::Page#dump
# File lib/innodb/page/trx_sys.rb, line 228 def dump super puts "trx_sys:" pp trx_sys puts end
Innodb::Page#each_region
# 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
Read a MySQL binary log information structure from a given position.
# 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
The doublewrite buffer information is located 200 bytes from the end of the page.
# File lib/innodb/page/trx_sys.rb, line 89 def pos_doublewrite_info size - 200 end
The local binary log information is located 1000 bytes from the end of the page.
# File lib/innodb/page/trx_sys.rb, line 83 def pos_mysql_binary_log_info size - 1_000 end
The master’s binary log information is located 2000 bytes from the end of the page.
# File lib/innodb/page/trx_sys.rb, line 77 def pos_mysql_master_log_info size - 2_000 end
# File lib/innodb/page/trx_sys.rb, line 67 def pos_rsegs_array pos_trx_sys_header + size_trx_sys_header end
The TRX_SYS header immediately follows the FIL header.
# File lib/innodb/page/trx_sys.rb, line 59 def pos_trx_sys_header pos_page_body end
# 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
# File lib/innodb/page/trx_sys.rb, line 93 def size_doublewrite_info Innodb::FsegEntry::SIZE + (2 * (4 + 4 + 4)) + 4 end
# File lib/innodb/page/trx_sys.rb, line 71 def size_mysql_log_info 4 + 8 + 100 end
# File lib/innodb/page/trx_sys.rb, line 63 def size_trx_sys_header 8 + Innodb::FsegEntry::SIZE end
Read the TRX_SYS headers and other information.
# 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