<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="986261">
  <date_last_updated>2012-08-06 07:49:21.034427+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/986261</bug_api_link>
    <bug_owner_link>https://api.launchpad.net/1.0/~elenst</bug_owner_link>
    <milestone_link>https://api.launchpad.net/1.0/maria/+milestone/5.1</milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/986261/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/986261/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/986261</bug_web_link>
  <owner>Elena Stepanova</owner>
  <assignee>Michael Widenius</assignee>
  <milestone_title>Maria 5.1</milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>Aria unit tests fail at ma_test2 line 316</title>
  <status>New</status>
  <importance>Low</importance>
  <created>2012-04-20 16:19:19.260940+00:00</created>
  <description>
<![CDATA[Initially reported on maria-discuss at launchpad: 
https://lists.launchpad.net/maria-discuss/msg00601.html

[16:34:05] ../storage/maria/unittest/ma_test_all-t .....................
73/830
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000
-e4096 -K ' (loop iteration 8.) at line 316
(errcode: 256, test: 83)

etc. 

The failure is only observed with -O2 (not -O1)]]>  </description>
  <activities>
    <activity datechanged="2012-04-20T16:19:19.260940+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Elena Stepanova</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2012-04-20T16:19:45.764398+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[aria]]>      </newvalue>
      <whatchanged>tags</whatchanged>
      <person>Elena Stepanova</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-20T16:20:02.552019+00:00">
      <oldvalue>
<![CDATA[aria]]>      </oldvalue>
      <newvalue>
<![CDATA[tests]]>      </newvalue>
      <whatchanged>tags</whatchanged>
      <person>Elena Stepanova</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-20T16:20:15.912364+00:00">
      <oldvalue>
<![CDATA[Undecided]]>      </oldvalue>
      <newvalue>
<![CDATA[Low]]>      </newvalue>
      <whatchanged>maria: importance</whatchanged>
      <person>Elena Stepanova</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-20T16:20:29.288645+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Michael Widenius (monty)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Elena Stepanova</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-20T16:20:33.851204+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.1]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Elena Stepanova</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-25T19:00:52.524328+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[http://bugs.gentoo.org/show_bug.cgi?id=410001]]>      </newvalue>
      <whatchanged>bug watch added</whatchanged>
      <person>Brian Evans</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-25T19:00:52.524328+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[gentoo]]>      </newvalue>
      <whatchanged>bug task added</whatchanged>
      <person>Brian Evans</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-25T19:02:26.393683+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[20000_all_mariadb_fix_tests.patch https://bugs.launchpad.net/gentoo/+bug/986261/+attachment/3103773/+files/20000_all_mariadb_fix_tests.patch]]>      </newvalue>
      <whatchanged>attachment added</whatchanged>
      <person>Brian Evans</person>
      <message></message>
    </activity>
    <activity datechanged="2012-08-06T07:49:19.880694+00:00">
      <oldvalue>
<![CDATA[Unknown]]>      </oldvalue>
      <newvalue>
<![CDATA[Medium]]>      </newvalue>
      <whatchanged>gentoo: importance</whatchanged>
      <person>Bug Watch Updater</person>
      <message></message>
    </activity>
  </activities>
  <comments>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/1" datecreated="2012-04-20T16:19:35.298377+00:00">
      <person>Elena Stepanova</person>
      <subject>
<![CDATA[Re: Aria unit tests fail at ma_test2 line 316]]>      </subject>
      <content>
<![CDATA[From what I see, ma_test2 has the array key3[5000], used in a loop which sets

n3=rnd(5000);
and then reads
key3[n3] == ...

while rnd(uint max_value) is
return (uint) ((rand() & 32767)/32767.0*max_value);

which means with some luck it can return max_value itself.

Luck happens, rnd returns 5000, key3[n3] reads something entirely wrong (in my case the value of 'silent' variable which is int and set to 1 as the unit test is launched with -s), the entire condition check with key3[n3] gets twisted, the bogus error occurs.

The following change fixes the problem for me, although maybe there are more elegant solutions.

=== modified file 'storage/maria/ma_test2.c'
--- storage/maria/ma_test2.c  2011-02-25 12:55:40 +0000
+++ storage/maria/ma_test2.c  2012-04-20 10:05:45 +0000
@@ -259,7 +259,7 @@
   for (i=0 ; i < recant ; i++)
   {
     ulong blob_length;
-    n1=rnd(1000); n2=rnd(100); n3=rnd(5000);
+    n1=rnd(1000); n2=rnd(100); n3=rnd(4999);
     sprintf((char*) record,"%6d:%4d:%8d:Pos: %4d ",n1,n2,n3,write_count);
     int4store(record+STANDARD_LENGTH-4,(long) i);
     fix_length(record,(uint) STANDARD_LENGTH+rnd(60));
]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/2" datecreated="2012-04-25T19:02:26.393683+00:00">
      <person>Brian Evans</person>
      <subject>
<![CDATA[Re: Aria unit tests fail at ma_test2 line 316]]>      </subject>
      <content>
<![CDATA[I've attached a patch which helped me resolve the random test failures.

There is a second spot for a possible index out of range that was not previously reported.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/3" datecreated="2012-03-28T14:08:18+00:00">
      <person>Paolo-pedroni</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[There is (and it's been there for a few months already) a new version (5.1.60) of mariadb on the mariadb site. An ebuild (even in the overlay) would be nice. I don't know (and I can't check at the moment) if a simple rename would do the trick.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/4" datecreated="2012-04-17T14:18:32+00:00">
      <person>Brian</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[MariaDB 5.1.62 is now in the overlay.
A patch from mysql-extras needs a change so please use the updated info.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/5" datecreated="2012-04-18T06:52:11+00:00">
      <person>kripton</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[MariaDB 5.1.62 is now in official tree as unstable :)
RESOLVED FIXED?]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/6" datecreated="2012-04-18T06:55:29+00:00">
      <person>Robin H. Johnson</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[Please run the testsuites. I'm not 100% happy with it.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/7" datecreated="2012-04-18T12:03:13+00:00">
      <person>Paolo-pedroni</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[With FEATURES="test -usersandbox" I get these errors:
[13:56:10] mysys/waiting_threads-t ..................................... ok        4 ms
[13:56:10] mysys/base64-t .............................................. ok      154 ms
[13:56:10] mysys/lf-t .................................................. ok      155 ms
[13:56:10] mysys/my_atomic-t ........................................... ok       62 ms
[13:56:10] mysys/bitmap-t .............................................. ok      289 ms
[13:56:10] strings/strings-t ........................................... ok        1 ms
[13:56:10] ../storage/maria/unittest/ma_pagecache_consist_64kHC-t ...... ok        8 ms
[13:56:10] ../storage/maria/unittest/ma_pagecache_consist_64k-t ........ ok        3 ms
[13:56:10] ../storage/maria/unittest/ma_test_loghandler_nologs-t ....... ok      299 ms
[13:56:11] ../storage/maria/unittest/ma_test_loghandler_noflush-t ...... ok       19 ms
[13:56:11] ../storage/maria/unittest/ma_pagecache_consist_1k-t ......... ok        8 ms
[13:56:11] ../storage/maria/unittest/ma_test_loghandler_long-t ......... ok     3861 ms
[13:56:15] ../storage/maria/unittest/ma_pagecache_consist_1kHC-t ....... ok        7 ms
[13:56:15] ../storage/maria/unittest/ma_test_loghandler_readonly-t ..... ok       55 ms
[13:56:15] ../storage/maria/unittest/ma_test_loghandler_purge-t ........ ok      256 ms
[13:56:15] ../storage/maria/unittest/ma_test_loghandler_max_lsn-t ...... ok      269 ms
[13:56:15] ../storage/maria/unittest/ma_test_loghandler_first_lsn-t .... ok       21 ms
[13:56:15] ../storage/maria/unittest/ma_pagecache_consist_64kRD-t ...... ok    33304 ms
[13:56:49] ../storage/maria/unittest/ma_pagecache_consist_1kRD-t ....... ok      443 ms
[13:56:49] ../storage/maria/unittest/ma_pagecache_single_1k-t .......... ok      333 ms
[13:56:49] ../storage/maria/unittest/ma_test_loghandler_multiflush-t ... ok     5572 ms
[13:56:55] ../storage/maria/unittest/ma_test_loghandler_pagecache-t .... ok       22 ms
[13:56:55] ../storage/maria/unittest/ma_test_loghandler_multithread-t .. ok    29585 ms
[13:57:25] ../storage/maria/unittest/ma_test_loghandler_multigroup-t ... ok    27926 ms
[13:57:53] ../storage/maria/unittest/ma_test_loghandler-t .............. ok     4067 ms
[13:57:57] ../storage/maria/unittest/ma_pagecache_rwconsist2_1k-t ...... ok        6 ms
[13:57:57] ../storage/maria/unittest/ma_pagecache_rwconsist_1k-t ....... ok        6 ms
[13:57:57] ../storage/maria/unittest/ma_pagecache_consist_64kWR-t ...... ok    43644 ms
[13:58:40] ../storage/maria/unittest/ma_pagecache_consist_1kWR-t ....... ok     1317 ms
[13:58:42] ../storage/maria/unittest/ma_pagecache_single_8k-t .......... ok     1846 ms
[13:58:44] ../storage/maria/unittest/ma_pagecache_single_64k-t ......... ok        8 ms
[13:58:44] ../storage/maria/unittest/ma_control_file-t ................. ok        1 ms
[13:58:44] ../storage/maria/unittest/trnman-t .......................... ok      687 ms
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... 77/830 
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e4096 -K ' (loop iteration 8.) at line 316
(errcode: 256, test: 83)
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... 85/830 
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e8192 -K ' (loop iteration 9.) at line 316
(errcode: 256, test: 85)

Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e16384 -E16384 -K -L ' (loop iteration 10.) at line 316
(errcode: 256, test: 87)
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... 238/830 
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e4096 -K -S' (loop iteration 8.) at line 316
(errcode: 256, test: 242)

Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e8192 -K -S' (loop iteration 9.) at line 316
(errcode: 256, test: 244)
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... 246/830 
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e16384 -E16384 -K -L -S' (loop iteration 10.) at line 316
(errcode: 256, test: 246)
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... 399/830 
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e4096 -K -M' (loop iteration 8.) at line 316
(errcode: 256, test: 401)

Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e8192 -K -M' (loop iteration 9.) at line 316
(errcode: 256, test: 403)

Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e16384 -E16384 -K -L -M' (loop iteration 10.) at line 316
(errcode: 256, test: 405)
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... 556/830 
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e4096 -K -M -T' (loop iteration 8.) at line 316
(errcode: 256, test: 560)

Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e8192 -K -M -T' (loop iteration 9.) at line 316
(errcode: 256, test: 562)
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... 564/830 
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e16384 -E16384 -K -L -M -T' (loop iteration 10.) at line 316
(errcode: 256, test: 564)
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... 719/830 
Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e4096 -K -M -T -C' (loop iteration 8.) at line 316
(errcode: 256, test: 719)

Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e8192 -K -M -T -C' (loop iteration 9.) at line 316
(errcode: 256, test: 721)

Failed test '../storage/maria/unittest/../ma_test2 -s -htmp -m10000 -e16384 -E16384 -K -L -M -T -C' (loop iteration 10.) at line 316
(errcode: 256, test: 723)
[13:58:44] ../storage/maria/unittest/ma_test_all-t ..................... Dubious, test returned 1 (wstat 256, 0x100)
Failed 15/830 subtests 
[14:00:37] ../dbug/tests-t ............................................. skipped: because dbug is disabled
[14:00:37]

Test Summary Report
-------------------
../storage/maria/unittest/ma_test_all-t                   (Wstat: 256 Tests: 830 Failed: 15)
  Failed tests:  83, 85, 87, 242, 244, 246, 401, 403, 405
                560, 562, 564, 719, 721, 723
  Non-zero exit status: 1
Files=35, Tests=145284, 267 wallclock secs ( 8.93 usr  0.30 sys + 138.85 cusr 56.43 csys = 204.51 CPU)
Result: FAIL
Failed 1/35 test programs. 15/145284 subtests failed.

Could it be because I have /var/tmp/portage on a tmpfs?]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/8" datecreated="2012-04-18T12:13:24+00:00">
      <person>Paolo-pedroni</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[Nope, same errors on a real filesystem as well. :-(]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/9" datecreated="2012-04-18T12:37:52+00:00">
      <person>Brian</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[(In reply to comment #4)
> With FEATURES="test -usersandbox" I get these errors:
[snip]
> 
> Test Summary Report
> -------------------
> ../storage/maria/unittest/ma_test_all-t                   (Wstat: 256 Tests:
> 830 Failed: 15)
>   Failed tests:  83, 85, 87, 242, 244, 246, 401, 403, 405
>                 560, 562, 564, 719, 721, 723
>   Non-zero exit status: 1
> Files=35, Tests=145284, 267 wallclock secs ( 8.93 usr  0.30 sys + 138.85
> cusr 56.43 csys = 204.51 CPU)
> Result: FAIL
> Failed 1/35 test programs. 15/145284 subtests failed.
> 
> Could it be because I have /var/tmp/portage on a tmpfs?

I've discovered that ma_test_all-t fails with -O2 or -Os in C(XX)FLAGS set.

They work fine if -O1 is set.

I've pointed this out on the MariaDB mailing list, but not sure if it's a MariaDB bug or gcc optimization issue.

@Robin: Do we need to force -O1 for tests only or should we always do it?]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/10" datecreated="2012-04-18T14:02:37+00:00">
      <person>kripton</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[I get the same test failures but they are not new since I get exactly the same test cases failing with version 5.1.50.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/11" datecreated="2012-04-23T13:14:31+00:00">
      <person>Brian</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[More info about ma_test_all-t that may be causing random test failures:
https://lists.launchpad.net/maria-discuss/msg00608.html]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/12" datecreated="2012-04-25T18:46:24+00:00">
      <person>Brian</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[Created attachment 310111
Fix index errors in the ma_test2 unit test binary

This patch fixes the errors on ma_test2 during unit tests.
It appears randomly due to the rnd function returning a random number between and including 0 to 5000. Since there are 5000 entries in the array, if rnd() pulls 5000, it's out of bounds.

When applied, my test box passes all tests with the following parameters.
FEATURES="test userpriv -usersandbox" USE='-cluster -latin1 embedded extraengine perl ssl community'

This also applies and fixes on mariadb-5.2.12 and mariadb-5.3.6.

5.2.12 only 1 test fails (plugins.unix_socket) due to Portage stripping $USER.
5.3.6 has the same test failure due to Portage]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/13" datecreated="2012-04-25T19:41:12+00:00">
      <person>Brian</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[Upstream bug on the test failure:
https://bugs.launchpad.net/maria/+bug/986261]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/986261/comments/14" datecreated="2012-08-02T19:32:05+00:00">
      <person>Brian</person>
      <subject>
<![CDATA[]]>      </subject>
      <content>
<![CDATA[Patch is now InCVS and will ship with the next mysql-extras release.]]>      </content>
    </comment>
  </comments>
  <messages>
    <message created="2012-04-25 19:02:26.393683+00:00" owner="Brian Evans">
<![CDATA[I've attached a patch which helped me resolve the random test failures.

There is a second spot for a possible index out of range that was not previously reported.]]>      <attachment link="https://bugs.launchpad.net/bugs/986261/+attachment/3103773" type="Patch">
        <title>20000_all_mariadb_fix_tests.patch</title>
        <file>LPexportBug986261_20000_all_mariadb_fix_tests.patch</file>
      </attachment>
    </message>
  </messages>
</launchpad-bug>
