Bug #43152 Assertion `bitmap_is_set_all(&table->s->all_set)' failed in handler::ha_reset
Submitted: 24 Feb 2009 15:20 Modified: 6 Apr 2011 1:32
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:6.0-bzr,5.4, next-mr, 5.6.1, 5.1, 5.0 OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any

[24 Feb 2009 15:20] Philip Stoev
Description:
When executing a random workload, the server asserted as follows:

mysqld: handler.cc:5480: int handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed.

#6  0x000000315a42bec9 in __assert_fail () from /lib64/libc.so.6
#7  0x0000000000815281 in handler::ha_reset (this=0x7f4ff8f4b860) at handler.cc:5480
#8  0x0000000000822ebc in ha_partition::reset (this=0x7f4ff8f69df0) at ha_partition.cc:5520
#9  0x0000000000815312 in handler::ha_reset (this=0x7f4ff8f69df0) at handler.cc:5488
#10 0x000000000072a68a in close_thread_table (thd=0x7f4ff8fbacf8, table_ptr=0x7f4ff8fbad88) at sql_base.cc:1510
#11 0x000000000072ab71 in close_open_tables (thd=0x7f4ff8fbacf8) at sql_base.cc:1222
#12 0x000000000072af60 in close_thread_tables (thd=0x7f4ff8fbacf8, skip_mdl=false) at sql_base.cc:1470
#13 0x00000000006deb4a in dispatch_command (command=COM_QUERY, thd=0x7f4ff8fbacf8, packet=0x7f4ff8fd2ab9 "", packet_length=96) at sql_parse.cc:1410
#14 0x00000000006def71 in do_command (thd=0x7f4ff8fbacf8) at sql_parse.cc:691
#15 0x00000000006ccef1 in handle_one_connection (arg=0x7f4ff8fbacf8) at sql_connect.cc:1146
#16 0x000000315b0073da in start_thread () from /lib64/libpthread.so.0
#17 0x000000315a4e627d in clone () from /lib64/libc.so.6

How to repeat:
With the RQG from test-extra-6.0/mysql-test/gentest:

$ perl runall.pl \
  --rows=10 \
  --threads=32 \
  --basedir=/build/bzr/6.0-falcon-team \
  --mask=582 \
  --queries=10000000 \
  --duration=900 \
  --engine=Falcon \
  --grammar=conf/combinations.yy \
  --gendata=conf/combinations.zz \
  --reporters=Deadlock,ErrorLog,Backtrace,Recovery \
  --mysqld=--loose-falcon-lock-wait-timeout=1 \
  --mysqld=--loose-innodb-lock-wait-timeout=1 \
  --mysqld=--log-output=none \
  --mysqld=--skip-safemalloc
[24 Feb 2009 18:04] Philip Stoev
This bug happens across a wide variety of workloads.
[27 Feb 2009 14:47] Peter Gulutzan
Compare Bug#43129 "failed assertion `bitmap_is_set_all(&table->s->all_set)' with concurrent inserts"
[5 Mar 2009 15:18] MySQL Verification Team
I got different crash output than the one reported on Ubuntu 8.10 64-bit with latest source mysql-6.0-falcon-team. Could you please see if still the original stack trace happens on your side?. I attached a file with the stack trace. Thanks in advance.
[28 Jul 2009 11:19] Philip Stoev
This bug is no longer repeatable, likely a duplicate of the other bugs that have been closed.
[18 Jan 2010 11:47] Philip Stoev
This is again repeatable, with the following RQG command (please pull fresh RQG from Launchpad):

perl pb2gentest.pl /build/bzr/mysql-next-mr /tmp/vardir - rqg_innodb_stress

This is going to cause the crash in about 50% of the cases, within a few minutes after takeoff.
[1 Feb 2010 14:46] Mattias Jonsson
I have tested with latest mysql-next-mr-bugfixing (alik@sun.com-20100111131051-ksxfc3lnu2wgcj7r) on ubuntu 9.10 x86_64 using both disk and ramdisk without repeating the bug.

Could you please be more specific on how to repeat? (hardware, os, mysql-version/rev-id...)
[2 Mar 2010 0: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".
[6 Oct 2010 12:18] Michael Widenius
The bug is still existing in MySQL 5.0 and forwards.

This is caused by some bitmap test functions are changing the bitmap other threads are using.

A bug fix for this can be found in MariaDB 5.1.51.
[19 Nov 2010 21:07] Sveta Smirnova
Michael,

thank you for the feedback. Could you please send us instructions how to repeat the problem and link to the fix: I found nothing related to bitmap in MariaDB 5.1.51 changelog.
[13 Jan 2011 15:23] Jon Olav Hauglid
Non-deterministic MTR test case:

CREATE TABLE t1 (a TEXT, b TEXT, PRIMARY KEY(a(1))) ENGINE=InnoDB;
INSERT INTO t1 VALUES('a',REPEAT('b',10000));

connect (con1, localhost, root);

let $try = 1000;
while ($try)
{
        connection default;
        --send UPDATE t1 SET a='a'
        connection con1;
        --send SELECT COUNT(*) FROM t1
        connection default;
        --reap
        connection con1;
        --reap
        dec $try;
}

connection default;
disconnect con1;
DROP TABLE t1;
[14 Jan 2011 13:04] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128743

3244 Jon Olav Hauglid	2011-01-14
      Bug #43152 Assertion `bitmap_is_set_all(&table->s->all_set)'
                 failed in handler::ha_reset
      
      This assertion could be triggered if two connections simultaneously
      executed two bitmap test functions on the same bitmap. Even if these
      functions have read-only schematics and have const bitmaps as
      parameters, several of them modified the internal state of the bitmap.
      With interleaved execution of two such functions it was possible for
      one function to modify the state of the same bitmap that the other
      function had just modified. This lead to an inconsistent state and
      could trigger the assert.
      
      Internally the bitmap uses 32 bit words for storage. Since bitmaps
      can contain any number of bits, the last word in the bitmap may
      not be fully used. A 32 bit mask is maintained where a bit is set
      if the corresponding bit in the last bitmap word is unused.
      The problem was that several test functions applies this mask to
      the last word. Some used bitwise AND and some used bitwise OR.
      This meant that if a function first used bitwise AND and another
      function then used bitwise OR before the first function tested
      the result, the result would be invalid.
      
      This patch fixes the problem by changing the implementation of
      8 bitmap functions that modified the bitmap state even if the 
      bitmap was declared const. These functions now preserves the
      internal state of the bitmap. This makes it possible for
      two connections to concurrently execute two of these functions
      on the same bitmap without issues.
      
      The patch also reactivates the built-in test of my_bitmap.
      
      No test case added as this would require adding several sync
      points to the bitmap functions. The patch has been tested with
      a non-deterministic test case posted on the bug report.
[14 Jan 2011 14:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128772

3244 Jon Olav Hauglid	2011-01-14
      Bug #43152 Assertion `bitmap_is_set_all(&table->s->all_set)'
                 failed in handler::ha_reset
      
      This assertion could be triggered if two connections simultaneously
      executed two bitmap test functions on the same bitmap. Even if these
      functions have read-only schematics and have const bitmaps as
      parameters, several of them modified the internal state of the bitmap.
      With interleaved execution of two such functions it was possible for
      one function to modify the state of the same bitmap that the other
      function had just modified. This lead to an inconsistent state and
      could trigger the assert.
      
      Internally the bitmap uses 32 bit words for storage. Since bitmaps
      can contain any number of bits, the last word in the bitmap may
      not be fully used. A 32 bit mask is maintained where a bit is set
      if the corresponding bit in the last bitmap word is unused.
      The problem was that several test functions applies this mask to
      the last word. Some used bitwise AND and some used bitwise OR.
      This meant that if a function first used bitwise AND and another
      function then used bitwise OR before the first function tested
      the result, the result would be invalid.
      
      This patch fixes the problem by changing the implementation of
      8 bitmap functions that modified the bitmap state even if the 
      bitmap was declared const. These functions now preserves the
      internal state of the bitmap. This makes it possible for
      two connections to concurrently execute two of these functions
      on the same bitmap without issues.
      
      The patch also reactivates the built-in test of my_bitmap.
      
      No test case added as this would require adding several sync
      points to the bitmap functions. The patch has been tested with
      a non-deterministic test case posted on the bug report.
[17 Jan 2011 11:37] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128936

3258 Jon Olav Hauglid	2011-01-17
      Bug #43152 Assertion `bitmap_is_set_all(&table->s->all_set)'
                 failed in handler::ha_reset
      
      This assertion could be triggered if two connections simultaneously
      executed two bitmap test functions on the same bitmap. Even if these
      functions have read-only schematics and have const bitmaps as
      parameters, several of them modified the internal state of the bitmap.
      With interleaved execution of two such functions it was possible for
      one function to modify the state of the same bitmap that the other
      function had just modified. This lead to an inconsistent state and
      could trigger the assert.
      
      Internally the bitmap uses 32 bit words for storage. Since bitmaps
      can contain any number of bits, the last word in the bitmap may
      not be fully used. A 32 bit mask is maintained where a bit is set
      if the corresponding bit in the last bitmap word is unused.
      The problem was that several test functions applies this mask to
      the last word. Some used bitwise AND and some used bitwise OR.
      This meant that if a function first used bitwise AND and another
      function then used bitwise OR before the first function tested
      the result, the result would be invalid.
      
      This patch fixes the problem by changing the implementation of
      8 bitmap functions that modified the bitmap state even if the 
      bitmap was declared const. These functions now preserves the
      internal state of the bitmap. This makes it possible for
      two connections to concurrently execute two of these functions
      on the same bitmap without issues.
      
      The patch also removes dead testing code from my_bitmap.c.
      These tests have already been moved to unittest/mysys/bitmap-t.c.
      
      No test case added as this would require adding several sync
      points to the bitmap functions. The patch has been tested with
      a non-deterministic test case posted on the bug report.
[4 Feb 2011 11:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/130391

3301 Jon Olav Hauglid	2011-02-04
      Bug #43152 Assertion `bitmap_is_set_all(&table->s->all_set)'
                 failed in handler::ha_reset
      
      This assertion could be triggered if two connections simultaneously
      executed two bitmap test functions on the same bitmap. Even if these
      functions have read-only schematics and have const bitmaps as
      parameters, several of them modified the internal state of the bitmap.
      With interleaved execution of two such functions it was possible for
      one function to modify the state of the same bitmap that the other
      function had just modified. This lead to an inconsistent state and
      could trigger the assert.
      
      Internally the bitmap uses 32 bit words for storage. Since bitmaps
      can contain any number of bits, the last word in the bitmap may
      not be fully used. A 32 bit mask is maintained where a bit is set
      if the corresponding bit in the last bitmap word is unused.
      The problem was that several test functions applies this mask to
      the last word. Sometimes the mask is negated and used to zero out
      the remainder of the last word and sometimes the mask is used as-is
      to fill the remainder of the last word with 1's. This meant that if
      a function first used the negated mask and another function then
      used the mask as-is (or vice-versa), the result would be invalid.
      
      This patch fixes the problem by changing the implementation of
      9 bitmap functions that modified the bitmap state even if the 
      bitmap was declared const. These functions now preserves the
      internal state of the bitmap. This makes it possible for
      two connections to concurrently execute two of these functions
      on the same bitmap without issues.
      
      The patch also removes dead testing code from my_bitmap.c.
      These tests have already been moved to unittest/mysys/bitmap-t.c.
      Existing test coverage of my_bitmap has been extended.
      
      No MTR test case added as this would require adding several sync
      points to the bitmap functions. The patch has been tested with
      a non-deterministic test case posted on the bug report.
     @ include/my_bit.h
        Removed now unused function.
     @ unittest/mysys/bitmap-t.c
        Extended test coverage of my_bitmap.
[10 Feb 2011 10:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/131004

3321 Jon Olav Hauglid	2011-02-10
      Bug #43152 Assertion `bitmap_is_set_all(&table->s->all_set)'
                 failed in handler::ha_reset
      
      This assertion could be triggered if two connections simultaneously
      executed two bitmap test functions on the same bitmap. For example,
      the assertion could be triggered if one connection executed UPDATE
      while a second connection executed SELECT on the same table.
      
      Even if bitmap test functions have read-only schematics and have
      const bitmaps as parameter, several of them modified the internal
      state of the bitmap. With interleaved execution of two such functions
      it was possible for one function to modify the state of the same
      bitmap that the other function had just modified. This lead to an
      inconsistent state and could trigger the assert.
      
      Internally the bitmap uses 32 bit words for storage. Since bitmaps
      can contain any number of bits, the last word in the bitmap may
      not be fully used. A 32 bit mask is maintained where a bit is set
      if the corresponding bit in the last bitmap word is unused.
      The problem was that several test functions applies this mask to
      the last word. Sometimes the mask wass negated and used to zero out
      the remainder of the last word and sometimes the mask wass used as-is
      to fill the remainder of the last word with 1's. This meant that if
      a function first used the negated mask and another function then
      used the mask as-is (or vice-versa), the first function would then
      get the wrong result.
      
      This patch fixes the problem by changing the implementation of
      9 bitmap functions that modified the bitmap state even if the 
      bitmap was declared const. These functions now preserve the
      internal state of the bitmap. This makes it possible for
      two connections to concurrently execute two of these functions
      on the same bitmap without issues.
      
      The patch also removes dead testing code from my_bitmap.c.
      These tests have already been moved to unittest/mysys/bitmap-t.c.
      Existing test coverage of my_bitmap has been extended.
      
      No MTR test case added as this would require adding several sync
      points to the bitmap functions. The patch has been tested with
      a non-deterministic test case posted on the bug report.
[6 Apr 2011 1:32] Paul DuBois
Noted in 5.1.57, 5.5.11, 5.6.2 changelogs.

Bitmap functions used in one thread could change bitmaps used by 
other threads, causing an assertion to be raised. 

CHANGESET - http://lists.mysql.com/commits/131946