Bug #41464 Falcon fails to update all matching rows in a query under concurrency
Submitted: 15 Dec 2008 9:42 Modified: 29 Jan 2009 16:02
Reporter: Philip Stoev Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S1 (Critical)
Version:6.0-falcon-team OS:Any
Assigned to: Kevin Lewis CPU Architecture:Any
Tags: F_ISOLATION

[15 Dec 2008 9:42] Philip Stoev
Description:
When two threads execute the following queries, both will report affected_rows = 1 even though both queries should match two rows each:

Thread1:

UPDATE `table10_falcon_int`
SET `int_key` = `int_key` + IF(`pk` % 2 = 1 , 10, -10)
WHERE `pk` >= 0 ORDER BY `pk` ASC LIMIT 2

Thread2:

UPDATE `table10_falcon_int`
SET `int_key` = `int_key` + IF(`pk` % 2 = 1 , 10, -10)
WHERE `pk` >= 1 ORDER BY `pk` ASC LIMIT 2

Note that Thread1 attempts to update rows with PK 0 and 1 and Thread2 attempts to update rows with PK 1 and 2. Since the updates are ordered by PK, there is no reason for those queries to silently succeed with affected_rows = 1. Instead, both updates should have been successfull, or, at the very least, some transactional error should have been returned.

This test works fine under Innodb and non-concurrent Falcon. No errors are printed by the server.

How to repeat:
RQG ZZ file creates a table with 10 rows, each with a PK and a single integer key column:

$tables = { rows => [10] , pk => [ 'integer' ] };

$fields = { types => [ 'int' ], indexes => [ 'key' ] };

$data = { numbers => [ '100' ] }

RQG: YY file:

query:
        UPDATE _table SET `int_key` = `int_key` + IF(`pk` % 2 = 1 , 10, -10) WHERE `pk` >= value ORDER BY `pk` ASC LIMIT 2 ;

value:
        0 | 1;

To run:

$ perl runall.pl \
  --basedir=/build/bzr/6.0-falcon-team/ \
  --engine=Falcon \
  --grammar=conf/transactions.yy \
  --gendata=conf/transactions.zz

Soon after takeoff, the table will become inconsistent, e.g. the sum of the values in the integer key column will no longer be 1000.
[29 Jan 2009 15:48] Kevin Lewis
Philip,  I am able to run RQG for transactions.yy successfully.  Are you sure this is still a problem?
[29 Jan 2009 16:02] Philip Stoev
This bug does not appear to be reproducible any more. I will reopen it if I see it again.