Bug #47923 New "mf_keycache.c" requires thread support
Submitted: 8 Oct 2009 18:42 Modified: 18 Dec 2009 11:43
Reporter: Joerg Bruehe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.0.87 OS:Any
Assigned to: Joerg Bruehe CPU Architecture:Any

[8 Oct 2009 18:42] Joerg Bruehe
Description:
The current code of "mf_keycache.c" will not compile unless there is thread support, the error is:
gcc -DDEFAULT_BASEDIR=\"/usr/local\" -DMYSQL_DATADIR="\"/usr/local/var\"" -DDEFAULT_CHARSET_HOME="\"/usr/local\"" -DSHAREDIR="\"/usr/local/share/mysql\"" -DDEFAULT_HOME_ENV=MYSQL_HOME -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX -DDEFAULT_SYSCONFDIR="\"/usr/local/etc\"" -DHAVE_CONFIG_H -I. -I../include -I../include -I../include -I.    -O3 -DDBUG_OFF    -MT mf_keycache.o -MD -MP -MF .deps/mf_keycache.Tpo -c -o mf_keycache.o mf_keycache.c
mf_keycache.c: In function ‘find_key_block’:
mf_keycache.c:1782: error: ‘my_thread_var’ undeclared (first use in this function)
mf_keycache.c:1782: error: (Each undeclared identifier is reported only once
mf_keycache.c:1782: error: for each function it appears in.)
mf_keycache.c:1783: error: dereferencing pointer to incomplete type
mf_keycache.c:1789: error: dereferencing pointer to incomplete type
mf_keycache.c:1791: error: dereferencing pointer to incomplete type
mf_keycache.c:1792: error: dereferencing pointer to incomplete type
make[2]: *** [mf_keycache.o] Error 1
make[2]: Leaving directory `/MySQL/REPO/V50/platform/mysql-5.0.87/mysys'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/MySQL/REPO/V50/platform/mysql-5.0.87'
make: *** [all] Error 2

This is no issue in a server build (which has thread support, so it doesn't happen), but it happens (in 5.0.87) when you specify "--without-server".

While I see no use for this module in "libmysys" unless we build a server, it still is contained.

How to repeat:
Configure "--without-server", try to build.

Suggested fix:
Enclose the whole section dealing with a key cache resize in "#ifdef THREAD":
If there is no thread support (single-threaded), a resize operation cannot be in progress when another request is processed in the key cache.

In 6.0, this would be the patch; 5.0 is identical (except for a slight line number shift):

--- /V60/push-6.0/mysys/mf_keycache.c   2009-09-28 15:47:56.000000000 +0200
+++ mysys/mf_keycache.c 2009-10-05 12:13:50.000000000 +0200
@@ -1757,6 +1757,7 @@
       - block assigned but not yet read from file (invalid data).
   */

+#if THREAD
   if (keycache->in_resize)
   {
     /* This is a request during a resize operation */
@@ -1998,6 +1999,9 @@
     }
     DBUG_RETURN(0);
   }
+#else /* THREAD */
+DBUG_ASSERT(!keycache->in_resize);
+#endif

   if (page_status == PAGE_READ &&
       (block->status & (BLOCK_IN_EVICTION | BLOCK_IN_SWITCH |

In the long run, a restructuring of the server file grouping that puts this module into a server-only library would be even better.
[8 Oct 2009 19:59] 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/86246

2817 Joerg Bruehe	2009-10-08
      Fix bug#47923  New "mf_keycache.c" requires thread support
      
      The bug is a compilation issue:
      Function "find_key_block()" had thread operations
      which were not guarded by "#if THREAD", add that now.
     @ mysys/mf_keycache.c
        Without thread-support, we are in a single-threaded world,
        so there is no parallelism, and the keycache cannot be
        within a resize operation while this request is being processed.
[8 Oct 2009 20:09] Joerg Bruehe
Running local tests with various "configure" combinations.
[9 Oct 2009 20:15] 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/86460

3639 Joerg Bruehe	2009-10-09 [merge]
      Upmerge the fixes for bug#47923 and bug#47957 from 5.1.
[15 Oct 2009 17:24] 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/87019

3639 Joerg Bruehe	2009-10-15 [merge]
      Upmerge the fixes for bug#47923 and bug#47957 from 5.1.
      
      This includes further changes which are needed in 6.0,
      see the comments for "storage/archive/Makefile.am"
      and "unittest/backup/Makefile.am".
     @ configure.in
        Upmerge from 5.1
        
        Specific in 6.0, we need a conditional "SERVER"
        which is used in "unittest/backup/" to not build some
        server-related tests if the build is "--without-server".
     @ mysys/mf_keycache.c
        Upmerge from 5.1
     @ storage/archive/Makefile.am
        See comment in "concurrency_test.c":
        That test cannot be used unless there is thread support
        in the client library.
        
        The code treated this as a runtime issue, but that is wrong:
        It is even a linkage issue, because the test program needs
        both "libmysqlclient" (from "concurrency_test.c") and
        "libmysyslt" (from "azio.c"), and these two will conflict
        unless it is the threaded client library.
        
        The solution is to make the build of this test program
        depend on "THREAD_SAFE_CLIENT".
     @ unittest/backup/Makefile.am
        The necessary "libbackupstream" will not be built
        unless the build includes the server, so building
        the test program must be restricted to that case.
[16 Oct 2009 10:21] Joerg Bruehe
Patch is pushed to the bugteam trees,
currently set at versions 5.0.88 and 5.1.41.
[16 Oct 2009 12:37] Bugs System
Pushed into 5.0.88 (revid:joerg@mysql.com-20091016122941-rf6z0keqvmlgjfto) (version source revid:joerg@mysql.com-20091016122941-rf6z0keqvmlgjfto) (merge vers: 5.0.88) (pib:13)
[16 Oct 2009 17:46] Paul DuBois
Noted in 5.0.88 changelog.

mysys/mf_keycache.c requires threading, but no test was made for
thread support. 

Setting report to NDI pending push to 5.1.x+.
[22 Oct 2009 6:33] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091022063126-l0qzirh9xyhp0bpc) (version source revid:alik@sun.com-20091019135554-s1pvptt6i750lfhv) (merge vers: 6.0.14-alpha) (pib:13)
[22 Oct 2009 7:05] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091022060553-znkmxm0g0gm6ckvw) (version source revid:alik@sun.com-20091019132831-5j6xs19ld16m7r8j) (merge vers: 5.5.0-beta) (pib:13)
[22 Oct 2009 19:48] Paul DuBois
Noted in 5.1.41, 5.5.0, 6.0.14 changelogs.
[18 Dec 2009 10:27] Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:43] Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 10:45] MC Brown
Added entry to 5.1.40-ndb-7.1.0
[18 Dec 2009 10:58] Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:11] MC Brown
Added entry to 5.1.41-ndb-6.2.19 and 5.1.42-ndb-6.3.31
[18 Dec 2009 11:12] Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)
[18 Dec 2009 11:43] MC Brown
Already in 5.1.41