List:Maria Storage Engine« Previous MessageNext Message »
From:Michael Widenius Date:November 30 2008 11:58am
Subject:re: Why do we sometimes write a CLR_END even if the operation failed?
View as plain text  
Hi!

>>>>> "Guilhem" == Guilhem Bichot <guilhem@stripped> writes:

Guilhem> Hello Monty,
Guilhem> I noticed this:
Guilhem> in ma_blockrec.c, function _ma_write_abort_block_record():

Guilhem>    if (delete_head_or_tail(info, ...
Guilhem>      res= 1;
Guilhem> ...
Guilhem>        if (delete_head_or_tail(info, block->page, ...
Guilhem>          res= 1;
Guilhem> ...
Guilhem>        if (free_full_page_range(info, block->page, block->page_count))
Guilhem>          res= 1;
Guilhem> ...
Guilhem>    if (share->now_transactional)
Guilhem>    {
Guilhem>      if (_ma_write_clr(info, info->cur_row.orig_undo_lsn,

Guilhem> So, if the first functions above failed, we still write the CLR. I think 
Guilhem> that's not correct: usually when there is a failure we exit immediately 
Guilhem> and don't log anything. Imagine that it's the first 
Guilhem> delete_head_or_tail() which failed: nothing was done, no reason to log.

Yes, we would always write a CLR.

This happens only in case of crashed disk writes (extremely seldom and
a fatal error) and I don't think that writhing an extra CRL (that
should be ignored by recovery) will cause any problems for us.

The other option would be to keep track if something was logged before
or not and then only write the clr if something was logged.  A the
time of writing that above I thought that was unnessary complex and
would add extra if's without any gain (assuming the CLR is skipped at recovery)

Guilhem> The only reason I could find for the current behaviour is if 
Guilhem> _ma_write_clr() does some operations (as a side-effect of the log record 
Guilhem> write) which are very necessary to leave the structures in an acceptable 
Guilhem> state.

Guilhem> There is the same in _ma_apply_undo_key_insert() and 
Guilhem> _ma_apply_undo_key_delete().

Same logic here.

Guilhem> On the other hand, in write_block_record() and 
Guilhem> _ma_apply_undo_row_insert(), _ma_write_clr() is not called in case of 
Guilhem> error earlier in the function.

This is becasue in this case we *known* without having to add extra
logic that there was noting written before.

Guilhem> I would like to make things uniform.

Assuming extra CLR's are skipped, is it worth to make things uniform
if they will only slow down the common case (with an 'if') without any
advantages?

Guilhem> Do you understand why some functions are behaving differently?

Yesa

Guilhem> Can we 
Guilhem> modify _ma_write_abort_block_record(), _ma_apply_undo_key_insert() and 
Guilhem> _ma_apply_undo_key_delete().

If there is a clear benefit of doing so or if extra CLR's are not skipped.

Regards,
Monty
Thread
Why do we sometimes write a CLR_END even if the operation failed?Guilhem Bichot27 Nov
  • re: Why do we sometimes write a CLR_END even if the operation failed?Michael Widenius30 Nov
    • Re: Why do we sometimes write a CLR_END even if the operation failed?Guilhem Bichot1 Dec