Bug #35537 Innodb doesn't increment handler_update and handler_delete
Submitted: 24 Mar 2008 21:44 Modified: 20 Jun 2010 0:53
Reporter: Eric Bergen (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:4.1, 5.0, 5.1, 6.0 OS:Any
Assigned to: Calvin Sun
Tags: Contribution, handler_delete, handler_update, v6
Triage: Triaged: D3 (Medium)

[24 Mar 2008 21:44] Eric Bergen
Description:
In ha_innodb.cc delete_row and update_row methods don't update handler statistics like myisam and other storage engines do. This patch is a quick fix. I would rather see the statistics management moved above the storage engine layer so this doesn't happen with other engines in the future.

How to repeat:
mysql> create table t (t int) engine=innodb;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t set t=1;
Query OK, 1 row affected (0.00 sec)

mysql> show status like 'handler%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| Handler_commit             | 10    |
| Handler_delete             | 0     |
| Handler_discover           | 0     |
| Handler_prepare            | 10    |
| Handler_read_first         | 2     |
| Handler_read_key           | 4     |
| Handler_read_next          | 0     |
| Handler_read_prev          | 0     |
| Handler_read_rnd           | 0     |
| Handler_read_rnd_next      | 62    |
| Handler_rollback           | 0     |
| Handler_savepoint          | 0     |
| Handler_savepoint_rollback | 0     |
| Handler_update             | 0     |
| Handler_write              | 67    |
+----------------------------+-------+
15 rows in set (0.00 sec)

mysql> delete from t where t = 1;
Query OK, 1 row affected (0.00 sec)

mysql> show status like 'handler%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| Handler_commit             | 12    |
| Handler_delete             | 0     |
| Handler_discover           | 0     |
| Handler_prepare            | 12    |
| Handler_read_first         | 3     |
| Handler_read_key           | 6     |
| Handler_read_next          | 0     |
| Handler_read_prev          | 0     |
| Handler_read_rnd           | 0     |
| Handler_read_rnd_next      | 80    |
| Handler_rollback           | 0     |
| Handler_savepoint          | 0     |
| Handler_savepoint_rollback | 0     |
| Handler_update             | 0     |
| Handler_write              | 82    |
+----------------------------+-------+
15 rows in set (0.00 sec)

Suggested fix:
diff -urN mysql-5.0.51a-orig/sql/ha_innodb.cc mysql-5.0.51a/sql/ha_innodb.cc
--- mysql-5.0.51a-orig/sql/ha_innodb.cc 2008-01-11 06:43:39.000000000 -0800
+++ mysql-5.0.51a/sql/ha_innodb.cc      2008-03-24 14:29:46.000000000 -0700
@@ -3495,6 +3495,9 @@
        int             error = 0;

        DBUG_ENTER("ha_innobase::update_row");
+
+        statistic_increment(current_thd->status_var.ha_update_count,
+                           &LOCK_status);

        ut_ad(prebuilt->trx ==
                 (trx_t*) current_thd->ha_data[innobase_hton.slot]);
@@ -3578,6 +3581,9 @@

        DBUG_ENTER("ha_innobase::delete_row");

+        statistic_increment(current_thd->status_var.ha_delete_count,
+                           &LOCK_status);
+
        ut_ad(prebuilt->trx ==
                 (trx_t*) current_thd->ha_data[innobase_hton.slot]);
[24 Mar 2008 22:40] Sveta Smirnova
Thank you for the report.

Verified as described.

You can relay on Handler_commit value though.
[25 Mar 2008 16:29] Heikki Tuuri
Calvin,

please fix this in 5.1 and 6.0.

--Heikki
[14 Apr 2008 17:41] Eric Bergen
Taso Du Val wants me to note that he actually found the bug. I just fixed it. :)
[25 Apr 2008 19:26] Calvin Sun
Pushed into InnoDB 5.1 repository.
[14 May 2008 15:21] Bugs System
Pushed into 5.1.25-rc
[15 May 2008 1:19] Paul Dubois
Noted in 5.1.25 changelog.

InnoDB was not updating the Handler_delete or Handler_update status
variables. 

Setting report to Patch queued pending push into 6.0.x.
[15 May 2008 15:53] Paul Dubois
Setting report to Need Doc Info pending push into 6.0.x.
[19 May 2008 20:18] Paul Dubois
Setting report to Patch queued pending re-push of this patch.
[22 May 2008 9:50] Bugs System
Pushed into 6.0.6-alpha
[27 May 2008 18:33] Paul Dubois
The push into 5.1 was reverted, so there is no 5.1.x changelog entry.
[27 May 2008 18:39] Paul Dubois
The push into 6.0.x was a null merge that changed nothing. Resetting report to Patch Approved pending further push of patch into 6.0.x.

The "parent" report for this set of bugs is Bug#32440.
[24 Jun 2008 21:49] Calvin Sun
Merged into 6.0.6-alpha, according to Tim. But the patch has not been pushed into 5.1 yet.
[25 Jun 2008 1:47] Paul Dubois
Noted in 6.0.6 changelog.

Setting report to Need Doc Info pending push into 5.1.x.
[5 Oct 2008 16:51] Jon Stephens
Hello,

Has this in fact been pushed to 5.1? May we please have the correct 3-part version number for the 5.1 fix so we can document and close?

Thanks!
[13 Jan 2009 22:54] Gary Pendergast
Could we get an update on this? Has the patched been pushed into 5.1 yet? Will it be pushed into 5.0 as well?
[12 Mar 2009 21:41] Paul Dubois
Noted in 5.1.31 changelog.

Setting report to NDI pending possible push into 5.0.x.
[13 Mar 2009 15:41] Calvin Sun
Close the bug and there is no plan to push the fix into 5.0.
[5 May 2010 15:06] Bugs System
Pushed into 5.1.47 (revid:joro@sun.com-20100505145753-ivlt4hclbrjy8eye) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[6 May 2010 14:09] Paul Dubois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug.
Re-closing.
[28 May 2010 5:46] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100524190136-egaq7e8zgkwb9aqi) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (pib:16)
[28 May 2010 6:16] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100524190941-nuudpx60if25wsvx) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[28 May 2010 6:44] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100524185725-c8k5q7v60i5nix3t) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[29 May 2010 23:01] Paul Dubois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug.
Re-closing.
[17 Jun 2010 11:47] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 12:24] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:11] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)