| Bug #40552 | Race condition around default_directories in load_defaults() | ||
|---|---|---|---|
| Submitted: | 6 Nov 2008 16:10 | Modified: | 27 Mar 16:26 |
| Reporter: | Alexey Kopytov | ||
| Status: | Closed | ||
| Category: | C API | Severity: | S3 (Non-critical) |
| Version: | 5.0, 5.1, 6.0 | OS: | Any |
| Assigned to: | Alexey Kopytov | Target Version: | 5.1+ |
| Tags: | crash, widespread, sporadic, test failure, pushbuild | ||
| Triage: | Triaged: D1 (Critical) | ||
[6 Nov 2008 16:10]
Alexey Kopytov
[6 Nov 2008 18:23]
Alexey Stroganov
I would add note that there is kind of workaround exists that may help to decrease significantly probability of the happening cases when race condition leads to segfault. Just add blank my.cnf files to places where libmysqlclient will look for them i.e. /etc/my.cnf and ~/.my.cnf.
[13 Nov 2008 3:36]
Vladislav Vaintroub
Removing mysql_options() from sysbench code will fix the problem. Don't know if this is an acceptable workaround.
[13 Nov 2008 3:48]
Vladislav Vaintroub
In previous comment of course sysbench problem is meant, not the race in client code.
This works because options are re-read only in some cases( non-default config file or ,
as in sysbench case, non-default group).
The patch against current sysbench trunk could be like below.
===================================================================
--- drv_mysql.c (revision 41)
+++ drv_mysql.c (working copy)
@@ -280,10 +280,8 @@
hosts_pos = SB_LIST_ITEM_NEXT(hosts_pos);
host = SB_LIST_ENTRY(hosts_pos, value_t, listitem)->data;
pthread_mutex_unlock(&hosts_mutex);
-
- mysql_options(con, MYSQL_READ_DEFAULT_GROUP, "sysbench");
- DEBUG("mysql_options(%p, MYSQL_READ_DEFAULT_GROUP, \"sysbench\")", con);
+
if (args.use_ssl)
{
ssl_key= "client-key.pem";
[27 Feb 10:26]
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/67809 2812 Alexey Kopytov 2009-02-27 Fix for bug #40552: Race condition around default_directories in load_defaults() load_defaults(), my_search_option_files() and my_print_default_files() utilized a global variable containing a pointer to thread local memory. This could lead to race conditions when those functions were called with high concurrency. Fixed by changing the interface of the said functions to avoid the necessity for using a global variable. Since we cannot change load_defaults() prototype for API compatibility reasons, it was renamed my_load_defaults(). Now load_defaults() is a thread-unsafe wrapper around a thread-safe version, my_load_defaults(). modified: include/my_sys.h mysys/default.c server-tools/instance-manager/instance_map.cc server-tools/instance-manager/options.cc server-tools/instance-manager/options.h sql-common/client.c
[16 Mar 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/69272 2840 Alexey Kopytov 2009-03-16 [merge] Manual merge of patch for bug #40552 into the team tree. Replaced a call to load_defaults() in sql_plugin.cc with its thread-safe version. modified: include/my_sys.h mysys/default.c server-tools/instance-manager/instance_map.cc server-tools/instance-manager/options.cc server-tools/instance-manager/options.h sql-common/client.c sql/sql_plugin.cc
[18 Mar 14:16]
Bugs System
Pushed into 6.0.11-alpha (revid:joro@sun.com-20090318122208-1b5kvg6zeb4hxwp9) (version source revid:joro@sun.com-20090317133112-41qn6aly7arljtlq) (merge vers: 6.0.11-alpha) (pib:6)
[19 Mar 4:17]
Paul DuBois
Noted in 6.0.11 changelog. The load_defaults(), my_search_option_files() and my_print_default_files() functions in the C client library were subject to a race condition in multi-threaded operation. Setting report to NDI pending push into 5.1.x.
[27 Mar 15:56]
Bugs System
Pushed into 5.1.34 (revid:joro@sun.com-20090327143448-wuuuycetc562ty6o) (version source revid:leonard@mysql.com-20090316090622-sr8lylqvsl1jrcnv) (merge vers: 5.1.34) (pib:6)
[27 Mar 16:26]
Paul DuBois
Noted in 5.1.34 changelog.
[9 May 18:39]
Bugs System
Pushed into 5.1.34-ndb-6.2.18 (revid:jonas@mysql.com-20090508185236-p9b3as7qyauybefl) (version source revid:jonas@mysql.com-20090508185236-p9b3as7qyauybefl) (merge vers: 5.1.34-ndb-6.2.18) (pib:6)
[9 May 19:36]
Bugs System
Pushed into 5.1.34-ndb-6.3.25 (revid:jonas@mysql.com-20090509063138-1u3q3v09wnn2txyt) (version source revid:jonas@mysql.com-20090509063138-1u3q3v09wnn2txyt) (merge vers: 5.1.34-ndb-6.3.25) (pib:6)
[9 May 20:34]
Bugs System
Pushed into 5.1.34-ndb-7.0.6 (revid:jonas@mysql.com-20090509154927-im9a7g846c6u1hzc) (version source revid:jonas@mysql.com-20090509154927-im9a7g846c6u1hzc) (merge vers: 5.1.34-ndb-7.0.6) (pib:6)
