Bug #3653 Records missing from some queries
Submitted: 4 May 2004 18:36 Modified: 12 Jun 2004 15:50
Reporter: Thomas Krystofiak Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.18 OS:Linux (Debian Linux 3.x)
Assigned to: CPU Architecture:Any

[4 May 2004 18:36] Thomas Krystofiak
Description:
Certain queries fail to return all records - when they should.  Other queries that appear to be syntactically identical do return all records.

For example:

select * from `dps27`.`orders` limit 0,5000;
[returns 129 rows]

select * from `dps27`.`orders` limit 0,4999;
[returns 131 rows - the correct number]

How to repeat:
You may not be able to repeat easily!  But here are the facts:
Apparently irrelevant changes to a query will cause rows to be dropped from the results.

Consider this query:

mysql> select * from `dps27`.`orders` limit 0,5000;

|      147 | 326         |          1 | 2331 Seven Hills Rd    |                  | Fairfield    |              22 | 98304       |                14 | 641-472-7034  |      326 | 2004-05-04 10:37:23 |             2 |           2 |       NULL |       3 |                       1 |          20.00 |     NULL |         0.00 |             NULL |      1 | Thomas Krystofiak   |               0.00 |      1 |                        NULL |      0.00 |    0.00 |                 0.00 |             NULL |                0.00 |
|      148 | 327         |          1 | 2331 Seven Hills Rd    |                  | Fairfield    |              22 | 98304       |                14 | 641-472-7034  |      327 | 2004-05-04 10:40:11 |             2 |           2 |       NULL |       3 |                       1 |          20.00 |     NULL |         0.00 |             NULL |      1 | Thomas Krystofiak   |               0.00 |      1 |                         123 |      0.00 |    0.00 |                 0.00 |             NULL |                0.00 |
|      149 | 328         |          1 | 2331 Seven Hills Rd    |                  | Fairfield    |              22 | 98304       |                14 | 641-472-7034  |      328 | 2004-05-04 10:42:05 |             2 |           2 |       NULL |       3 |                       1 |          20.00 |     NULL |         0.00 |             NULL |      1 | Thomas Krystofiak   |               0.00 |      1 |                         124 |      0.00 |    0.00 |                 0.00 |             NULL |                0.00 |

129 rows in set (0.00 sec)

Notice that 129 rows are returned.  I only show the last three records here.  Missing are orderNumber 329 and 330 (the two most recently added records).  orderNumber is the second column returned.

Then I run this query, which I assume should be functionally identical:

mysql> select * from dps27.orders limit 0,5000;

|      149 | 328         |          1 | 2331 Seven Hills Rd    |                  | Fairfield    |              22 | 98304       |                14 | 641-472-7034  |      328 | 2004-05-04 10:42:05 |             2 |           2 |       NULL |       3 |                       1 |          20.00 |     NULL |         0.00 |             NULL |      1 | Thomas Krystofiak   |               0.00 |      1 |                         124 |      0.00 |    0.00 |                 0.00 |             NULL |                0.00 |
|      150 | 329         |          1 | 2331 Seven Hills Rd    |                  | Fairfield    |              22 | 98304       |                14 | 641-472-7034  |      329 | 2004-05-04 10:46:45 |             2 |           2 |       NULL |       3 |                       1 |          20.00 |     NULL |         0.00 |             NULL |      3 | Thomas Krystofiak   |               0.00 |      3 |                         125 |      0.00 |    0.00 |                 0.00 |             NULL |                0.00 |
|      151 | 330         |          1 | 2331 Seven Hills Rd    |                  | Fairfield    |              22 | 98304       |                14 | 641-472-7034  |      330 | 2004-05-04 10:54:08 |             2 |           2 |       NULL |       3 |                       1 |          20.00 |     NULL |         0.00 |             NULL |      3 | Thomas Krystofiak   |               0.00 |      3 |                         127 |      0.00 |    0.00 |                 0.00 |             NULL |                0.00 |

131 rows in set (0.00 sec)

Now I get all 131 records – including the missing last two records.

I find that almost any variation I make on the first query will cause all records to be returned, including all of these examples.

select * from `dps27`.`orders` limit 0,5001;
select * from `dps27`.`orders` limit 0,4999;
select * from `dps27`.`orders` where ordersID > 0 limit 0,5001;
select * from `orders` limit 0,5000;
select * from orders limit 0,5000;
select * from dps27.orders limit 0,5000;
select * from `dps27`.`orders` limit 0,131;
select * from `dps27`.`orders`;
select orderNumber from `dps27`.`orders` limit 0,5000;

But we believe that there are other queries that are also failing to return certain rows – although just now the only one that consistently fails to return all rows is this one:

select * from `dps27`.`orders` limit 0,5000;
[12 May 2004 15:50] MySQL Verification Team
Thank you so much for writting to us.

In order to be able to repeat the bug we definitely need a table in question.

You can upload it (tarred and gzipped) to this record).

Also do note that Debian binaries sometimes are not built well.
[14 Feb 2005 22:54] 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".