List:Internals« Previous MessageNext Message »
From:Mats Kindahl Date:May 11 2010 7:25am
Subject:Re: HA_EXTRA_WRITE_CAN_REPLACE and row based replication
View as plain text  
Hi Zardosht,

The flag HA_EXTRA_WRITE_CAN_REPLACE only is set on the slave for Write
rows when --slave-exec-mode is IDEMPOTENT *or when the NDB Cluster
engine is used*. In other words, the NDB engine is hardcoded to always
use IDEMPOTENT.

You can see the check in
Write_rows_log_event::do_before_row_operation() at log_event.cc:8314
(or in that vicinity).

Just my few cents,
Mats Kindahl

On 05/10/2010 04:04 PM, Zardosht Kasheff wrote:
> Hello all,
> 
> I want my storage engine to take advantage of the
> HA_EXTRA_WRITE_CAN_REPLACE flag so that when this flag is set, in
> handler::write_row, I silently overwrite the data if a duplicate is
> found.
> 
> I cannot get this to work with row-based replication. Suppose the
> following is executed on the master:
> CREATE TABLE t1(`a` INT, `b` DATE DEFAULT NULL, `c` INT DEFAULT NULL,
> PRIMARY KEY(`a`)) ENGINE=$engine DEFAULT CHARSET=LATIN1;
> INSERT INTO t1(a,b,c) VALUES (1,'1111-11-11', 1);
> REPLACE INTO t1(a,b,c) VALUES (1,'1111-11-11', 2);
> 
> In the last statement, in my implementation of hander::write_row, I
> find the duplicate of '1' internally, overwrite the old row with the
> new row, and return success. However, on the replicated server, my
> insert statement gets a duplicate key error, because the slave has not
> set the HA_EXTRA_WRITE_CAN_REPLACE flag.
> 
> My questions:
>  - How does this flag work with respect to replication? It does not
> seem to be getting set, and as a result, the slave fails to execute
> the "replace"
>  - I think NDB takes care of this scenario. How does this work in NDB?
>  - Does replication of "replace into" work from an NDB master to a
> MyISAM slave? I ask because MyISAM ignores the
> "HA_EXTRA_WRITE_CAN_REPLACE" flag.
> 
> Thanks
> -Zardosht
> 

-- 
Mats Kindahl
Senior Software Engineer
Database Technology Group
Sun Microsystems
Thread
HA_EXTRA_WRITE_CAN_REPLACE and row based replicationZardosht Kasheff10 May
  • Re: HA_EXTRA_WRITE_CAN_REPLACE and row based replicationMats Kindahl11 May
    • Re: HA_EXTRA_WRITE_CAN_REPLACE and row based replicationSergei Golubchik11 May
      • Re: HA_EXTRA_WRITE_CAN_REPLACE and row based replicationMats Kindahl11 May
        • Re: HA_EXTRA_WRITE_CAN_REPLACE and row based replicationZardosht Kasheff11 May
          • Re: HA_EXTRA_WRITE_CAN_REPLACE and row based replicationZardosht Kasheff11 May
          • Re: HA_EXTRA_WRITE_CAN_REPLACE and row based replicationMats Kindahl11 May
            • Re: HA_EXTRA_WRITE_CAN_REPLACE and row based replicationZardosht Kasheff11 May