List:Internals« Previous MessageNext Message »
From:Kristian Nielsen Date:November 25 2009 10:08am
Subject:Re: Primary key is miss in row based replication.
View as plain text  
Yuan Wang <wangyuanzju@stripped> writes:

> Sorry but I can't catch your meaning. Calling bitmap_set_all() in
> binlog_log_row() has nothing to do with read_set, and the engine read
> just the columns needed in read_set. So calling bitmap_set_all()  will
> write all columns in before_record. However, those columns that are
> not denoted in read_set is already missing in before_record, for the
> engine just doesn't read them. So you will write out some NULLs or
> garbage.

If I recall correctly, there are two different kinds of behaviour here among
different engines.

I believe some (most?) engines don't really use the read_set, so read the full
row always (Not 100% sure, also this might have changed, but the read_set was
not there from the start AFAIK).

Other engines _do_ use the read_set, for example NDB (I was told that read_set
was added originally to support NDB). And in NDB, the storage engine
explicitly adds the primary key columns to the set of columns to be read, even
if they are not included in the read_set. For example:

  // Define attributes to read
  for (i= 0; i < table_share->fields; i++) 
  {
    Field *field= table->field[i];
    if (bitmap_is_set(table->read_set, i) ||
        ((field->flags & PRI_KEY_FLAG)))
    {      
      if (get_ndb_value(op, field, i, buf))
        ERR_RETURN(op->getNdbError());
    } 

The (field->flags & PRI_KEY_FLAG) condition is there to include all primary
key columns.

So I think you need to do something similar in your engine, ie. read primary
key columns unconditionally.

I think there are also cases where a storage engine may (or should?) modify
the read_set and write_set. Unfortunately, the exact semantics of read_set and
write_set was always a bit fuzzy ...

Hope this helps,

 - Kristian.
Thread
Primary key is miss in row based replication.Yuan Wang20 Nov
  • Re: Primary key is miss in row based replication.Venu Kalyan20 Nov
  • Re: Primary key is miss in row based replication.Venu Kalyan20 Nov
  • Re: Primary key is miss in row based replication.Mats Kindahl20 Nov
    • Re: Primary key is miss in row based replication.Yuan Wang21 Nov
      • Re: Primary key is miss in row based replication.Mats Kindahl24 Nov
        • Re: Primary key is miss in row based replication.Yuan Wang25 Nov
          • Re: Primary key is miss in row based replication.Kristian Nielsen25 Nov
          • Re: Primary key is miss in row based replication.Mats Kindahl25 Nov
            • Re: Primary key is miss in row based replication.Yuan Wang26 Nov
              • Re: Primary key is miss in row based replication.Kristian Nielsen26 Nov
                • Re: Primary key is miss in row based replication.Mats Kindahl26 Nov
              • Re: Primary key is miss in row based replication.Mats Kindahl26 Nov
Re: Primary key is miss in row based replication.Yuan Wang20 Nov
  • Re: Primary key is miss in row based replication.Mats Kindahl20 Nov
    • Re: Primary key is miss in row based replication.Yuan Wang20 Nov
  • Re: Primary key is miss in row based replication.Mats Kindahl20 Nov
    • Re: Primary key is miss in row based replication.Yuan Wang20 Nov
      • Re: Primary key is miss in row based replication.Mats Kindahl20 Nov