List:Internals« Previous MessageNext Message »
From:Guilhem Bichot Date:June 18 2007 2:59pm
Subject:Re: CREATE INDEX is not committed?
View as plain text  
Hello Marko,

On Mon, Jun 18, 2007 at 12:06:33PM +0300, Marko Mäkelä wrote:
> On Wed, Jun 13, 2007 at 04:35:35PM +0200, Guilhem Bichot wrote:
> > On Wed, Jun 13, 2007 at 03:56:34PM +0300, Marko Mäkelä wrote:
> > > I wonder what the correct behavior is.  I would expect MySQL to commit
> > > before and after handler::add_index().
> > 
> > After: I agree. Before: why?
> 
> If mysqld is killed during data dictionary operations, I suspect that
> the rollback after InnoDB crash recovery will not delete or un-rename
> the .frm file.  In this case (fast ALTER TABLE), MySQL could believe
> that the table was altered.  Based on the output of SHOW CREATE TABLE,
> the user would assume that all preceding transactions were committed.

Anyway, a commit before the add_index() wouldn't help: the new frm
would be committed and not be consistent with InnoDB's dictionary
which hasn't added the index. Or I don't understand.
If we view the frm and innodb's dictionary as two resources, to have
them always in sync after a crash we would need two-phase commit
between them. In sql_table.cc in 5.1, we have the "ddl_log" (used only
when altering partitions if I remember correctly), which can be used
to finish re-partitioning if a crash happened in the middle (it
handles delete/replace/create operations on tables, which happen
during re-partitioning). It could be extended to handle any crash
during ALTER TABLE (out of partitions), but that would require help
from the engine. For example, at restart we find out in this ddl_log
that we wanted to create a new index in InnoDB, we would ask InnoDB to
create the new index, and InnoDB would create if if not already (but
give no error if already created, for the ddl_log to be idempotent).

Something for the future I guess ;)

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Mr. Guilhem Bichot <guilhem@stripped>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Lead Software Engineer
/_/  /_/\_, /___/\___\_\___/   Bordeaux, France
       <___/   www.mysql.com   
Thread
CREATE INDEX is not committed?Marko Mäkelä13 Jun
  • Re: CREATE INDEX is not committed?Guilhem Bichot13 Jun
    • Re: CREATE INDEX is not committed?Marko Mäkelä13 Jun
      • Re: CREATE INDEX is not committed?Guilhem Bichot13 Jun
        • Re: CREATE INDEX is not committed?Marko Mäkelä18 Jun
          • Re: CREATE INDEX is not committed?Marko Mäkelä18 Jun
            • Re: CREATE INDEX is not committed?Guilhem Bichot18 Jun
              • Re: CREATE INDEX is not committed?Marko Mäkelä20 Jun
                • Re: CREATE INDEX is not committed?Ramil Kalimullin20 Jun
                  • Re: CREATE INDEX is not committed?Marko Mäkelä20 Jun
          • Re: CREATE INDEX is not committed?Guilhem Bichot18 Jun
Re: CREATE INDEX is not committed?Marko Mäkelä21 Jun
  • Smart ALTER TABLE dropping non-existing tmp table (Re: CREATEINDEX is not committed?)Marko Mäkelä13 Aug