according to mysql reference, 6-byte transaction ID field will be added in the cluster index record and will be set to the value the transaction which create/modifed it. my question is: let say transaction 1, 2 are active in mysql and 2 modified a record, meanwhile set its transaction ID to 2. release the lock and exit. then transaction 1 entered in and modified the same record again, will transaction ID be modified smaller than 2 to 1?
If you're interested in InnoDB internal storage formats, you might like to get Jeremy Cole's Innodb_ruby tool.
I tried creating a table test.foo
with 1 row, and updated the row with a series of transactions. I can then use Jeremy Cole's script to dump the page:
innodb_space -s ibdata1 -T test/foo -p 3 page-dump
...
records:
{:format=>:compact,
:offset=>125,
:header=>
{:next=>112,
:type=>:conventional,
:heap_number=>2,
:n_owned=>0,
:min_rec=>false,
:deleted=>false,
:nulls=>[],
:lengths=>{},
:externs=>[],
:length=>5},
:next=>112,
:type=>:clustered,
:key=>[{:name=>"id", :type=>"BIGINT UNSIGNED", :value=>7}],
:row=>[],
:sys=>
[{:name=>"DB_TRX_ID", :type=>"TRX_ID", :value=>2843},
{:name=>"DB_ROLL_PTR",
:type=>"ROLL_PTR",
:value=>
{:is_insert=>true, :rseg_id=>20, :undo_log=>{:page=>335, :offset=>272}}}],
:length=>21,
:transaction_id=>2843,
:roll_pointer=>
{:is_insert=>true, :rseg_id=>20, :undo_log=>{:page=>335, :offset=>272}}}
You can see under the :sys
key there's the DB_TRX_ID. As I make further updates to the row, this value is changed. You can try it yourself and see how the value changes.
Read Jeremy's series of blog posts to understand more about the InnoDB format:
Here's a list of his blog posts: https://blog.jcole.us/innodb/