Permalink
Browse files

BUG#12662190:COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SL…

…AVE, COM_BEGIN IS

PROBLEM:

--------

When binary log statements are replayed on the slave, BEGIN is represented

in com_counters but COMMIT is not. Similarly in 'ROW' based replication

'INSERT','UPDATE',and 'DELETE' com_counters are not getting incremented

when the binary log statements are replayed at slave.

ANALYSIS:
---------

In 'ROW' based replication for COMMIT,INSERT,UPDATE and DELETE operations
following special events are invoked.
Xid_log_event,Write_rows_log_event,Update_rows_log_event,Update_rows_log_event.

The above mentioned events doesn't go through the parser where the
'COM_COUNTERS' are incremented.

FIX:
-----
Increment statements are added at appropriate events.
Respective functions are listed below.

'Xid_log_event::do_apply_event'
'Write_rows_log_event::do_before_row_operations'
'Update_rows_log_event::do_before_row_operations'
'Delete_rows_log_event::do_before_row_operations'
--BZR--
revision-id: sujatha.sivakumar@oracle.com-20120412053739-461qaaao708njv7f
property-branch-nick: Bug12662190
property-file-info: ld7:file_id65:sp1f-log_event.cc-19700101030959-msmqlflsngxosswid2hpzxly5vfqdddc7:message119:Added code to increment counts for 'COM_INSERT','COM_UPDATE',
property-file-info: 'COM_DELETE' and 'COM_COMMIT'during ROW based replicaiton4:path16:sql/log_event.ccee
testament3-sha1: 03a97ebea95b3d62ad79b50a08cc607f81cdb5ec
  • Loading branch information...
Sujatha Sivakumar Davi Arnaut
Sujatha Sivakumar authored and Davi Arnaut committed Apr 12, 2012
1 parent ab7b643 commit d4c5a08a4321c3abace8d6744ab20d3c888a020d
@@ -6,6 +6,15 @@
# First we test tables with only an index.
#
+#BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS
+#Testing command counters -BEFORE
+#Storing the before counts of Slave
+connection slave;
+let $slave_com_commit_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commit', Value, 1);
+let $slave_com_insert_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1);
+let $slave_com_delete_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1);
+let $slave_com_update_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1);
+
connection master;
eval CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)$extra_index_t1) ENGINE = $type ;
SELECT * FROM t1;
@@ -40,6 +49,32 @@ SELECT * FROM t1 ORDER BY C1,C2;
sync_slave_with_master;
SELECT * FROM t1 ORDER BY C1,C2;
+#BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS
+#Testing command counters -AFTER
+#Storing the after counts of Slave
+connection slave;
+let $slave_com_commit_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commit', Value, 1);
+let $slave_com_insert_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1);
+let $slave_com_delete_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1);
+let $slave_com_update_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1);
+
+#Commit count check
+--let $assert_text= Counter for COM_COMMIT is consistent with the number of actual commits
+--let $assert_cond= $slave_com_commit_after - $slave_com_commit_before = 4
+--source include/assert.inc
+#Insert count check
+--let $assert_text= Counter for COM_INSERT is consistent with the number of actual inserts
+--let $assert_cond= $slave_com_insert_after - $slave_com_insert_before = 2
+--source include/assert.inc
+#Delete count check
+--let $assert_text= Counter for COM_DELETE is consistent with the number of actual deletes
+--let $assert_cond= $slave_com_delete_after - $slave_com_delete_before = 1
+--source include/assert.inc
+#Update count check
+--let $assert_text= Counter for COM_UPDATE is consistent with the number of actual updates
+--let $assert_cond= $slave_com_update_after - $slave_com_update_before = 1
+--source include/assert.inc
+
# Testing update with a condition that does not match any rows, but
# which has a match for the index.
connection master;
@@ -49,6 +49,10 @@ A B
A I
X Y
X Z
+include/assert.inc [Counter for COM_COMMIT is consistent with the number of actual commits]
+include/assert.inc [Counter for COM_INSERT is consistent with the number of actual inserts]
+include/assert.inc [Counter for COM_DELETE is consistent with the number of actual deletes]
+include/assert.inc [Counter for COM_UPDATE is consistent with the number of actual updates]
UPDATE t1 SET c2 = 'Q' WHERE c1 = 'A' AND c2 = 'N';
SELECT * FROM t1 ORDER BY c1,c2;
C1 C2
@@ -49,6 +49,10 @@ A B
A I
X Y
X Z
+include/assert.inc [Counter for COM_COMMIT is consistent with the number of actual commits]
+include/assert.inc [Counter for COM_INSERT is consistent with the number of actual inserts]
+include/assert.inc [Counter for COM_DELETE is consistent with the number of actual deletes]
+include/assert.inc [Counter for COM_UPDATE is consistent with the number of actual updates]
UPDATE t1 SET c2 = 'Q' WHERE c1 = 'A' AND c2 = 'N';
SELECT * FROM t1 ORDER BY c1,c2;
C1 C2
View
@@ -5577,6 +5577,11 @@ int Xid_log_event::do_apply_event(Relay_log_info const *rli)
res= trans_commit(thd); /* Automatically rolls back on error. */
thd->mdl_context.release_transactional_locks();
+ /*
+ Increment the global status commit count variable
+ */
+ status_var_increment(thd->status_var.com_stat[SQLCOM_COMMIT]);
+
return res;
}
@@ -8732,6 +8737,12 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability
{
int error= 0;
+ /*
+ Increment the global status insert count variable
+ */
+ if (get_flags(STMT_END_F))
+ status_var_increment(thd->status_var.com_stat[SQLCOM_INSERT]);
+
/**
todo: to introduce a property for the event (handler?) which forces
applying the event in the replace (idempotent) fashion.
@@ -9665,6 +9676,12 @@ Delete_rows_log_event::Delete_rows_log_event(const char *buf, uint event_len,
int
Delete_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const)
{
+ /*
+ Increment the global status delete count variable
+ */
+ if (get_flags(STMT_END_F))
+ status_var_increment(thd->status_var.com_stat[SQLCOM_DELETE]);
+
if ((m_table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) &&
m_table->s->primary_key < MAX_KEY)
{
@@ -9794,6 +9811,12 @@ Update_rows_log_event::Update_rows_log_event(const char *buf, uint event_len,
int
Update_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const)
{
+ /*
+ Increment the global status update count variable
+ */
+ if (get_flags(STMT_END_F))
+ status_var_increment(thd->status_var.com_stat[SQLCOM_UPDATE]);
+
if (m_table->s->keys > 0)
{
// Allocate buffer for key searches

0 comments on commit d4c5a08

Please sign in to comment.