Bug #71531 Select count(distinct(col)) from table returns zero
Submitted: 30 Jan 2014 17:00 Modified: 28 Feb 2014 17:30
Reporter: Bharathi Ravikumar Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:5.5.8 OS:Linux (Cent OS 6.4)
Assigned to: CPU Architecture:Any

[30 Jan 2014 17:00] Bharathi Ravikumar
Description:
We are using mysql (5.5.8) ,  I am facing a weird  bug in that.   Performing "select count(distinct(col)) from table" returns 0 , not all the times.  According to slow query log , 

Rows Sent : 1 , Rows Examined : Above 200 million rows , Time Taken : 9360 seconds. 

MYSQL Details 

Version : 5.5.8
Engine  : Inno DB 

Show Create table Details: 

CREATE TABLE `LOGINAudit` (
     `ID` bigint(19) NOT NULL DEFAULT '0',
     `NAME` varchar(100) NOT NULL,
      `HASH` varchar(255) DEFAULT NULL,
       `TIMESTAMP` bigint(19) DEFAULT NULL, 
      KEY `LOGINAudit_hdx` (`TIMESTAMP` , `HASH`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Query:

SELECT COUNT(DISTINCT(HASH)) from LOGINAudit;
  

How to repeat:
I don't know , how to reproduce this issue. It seems to be very very rare bug I had faced in mysql.
[30 Jan 2014 17:15] Sveta Smirnova
Thank you for the report.

But version 5.5.8 is very old and many bugs were fixed since. Please try with current version 5.5.35 and the problem still exists provide output of SELECT COUNT(*) FROM LOGINAudit WHERE HASH IS NOT NULL;
[30 Jan 2014 17:24] Bharathi Ravikumar
@Sveta Smirnova,

Thank you. 

It is running in our production setup. So , migrating to new mysql would take more time. Surely , we will try to migrate to new version.  

Is there any alternate solution for this?
[30 Jan 2014 17:30] Sveta Smirnova
Thank you for the feedback.

This database is for bug in MySQL code and not for customer support. Support on using our products is available both free in our forums athttp://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

So here I can only discuss how to repeat this issue on our side, so we can confirm this is bug in MySQL code. Since we don't backport bug fixes anyway you still have to upgrade even if we confirm this is bug in the MySQL code.

For now, while you are deciding if you can upgrade, please send output of the statement which I asked you about in previous comment.
[1 Mar 2014 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".