|
1 |
| -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. |
| 1 | +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 2 |
|
3 | 3 | This program is free software; you can redistribute it and/or modify
|
4 | 4 | it under the terms of the GNU General Public License as published by
|
@@ -195,7 +195,13 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
|
195 | 195 | my_free(share);
|
196 | 196 | goto err;
|
197 | 197 | }
|
198 |
| - thr_lock_init(&share->lock); |
| 198 | + /* |
| 199 | + Do not initialize THR_LOCK object for internal temporary tables. |
| 200 | + It is not needed for such tables. Calling thr_lock_init() can |
| 201 | + cause scalability issues since it acquires global lock. |
| 202 | + */ |
| 203 | + if (!create_info->internal_table) |
| 204 | + thr_lock_init(&share->lock); |
199 | 205 | mysql_mutex_init(hp_key_mutex_HP_SHARE_intern_lock,
|
200 | 206 | &share->intern_lock, MY_MUTEX_INIT_FAST);
|
201 | 207 | if (!create_info->internal_table)
|
@@ -299,10 +305,12 @@ void heap_drop_table(HP_INFO *info)
|
299 | 305 |
|
300 | 306 | void hp_free(HP_SHARE *share)
|
301 | 307 | {
|
302 |
| - if (share->open_list.data) /* If not internal table */ |
| 308 | + my_bool not_internal_table= (share->open_list.data != NULL); |
| 309 | + if (not_internal_table) /* If not internal table */ |
303 | 310 | heap_share_list= list_delete(heap_share_list, &share->open_list);
|
304 | 311 | hp_clear(share); /* Remove blocks from memory */
|
305 |
| - thr_lock_delete(&share->lock); |
| 312 | + if (not_internal_table) |
| 313 | + thr_lock_delete(&share->lock); |
306 | 314 | mysql_mutex_destroy(&share->intern_lock);
|
307 | 315 | my_free(share->name);
|
308 | 316 | my_free(share);
|
|
0 commit comments