3591 Marko Mäkelä 2011-04-18
Fix a memory leak introduced in the Bug#11833462 fix
(bzr revision id sunny.bains@stripped).
trx_free(): Move some assertions to trx_free_for_background().
trx_free_prepared(): Use trx_free() to free most data structures.
modified:
storage/innobase/trx/trx0trx.c
3590 Sunny Bains 2011-04-18
WL#5758: Improve Thread Scheduling (performance)
Factor out the concurrency management code to a separate file.
rb://650 Approved by Jimmy Yang.
added:
storage/innobase/include/srv0conc.h
storage/innobase/srv/srv0conc.c
modified:
storage/innobase/CMakeLists.txt
storage/innobase/include/srv0srv.h
storage/innobase/srv/srv0srv.c
=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c revid:sunny.bains@oracle.com-20110418021716-8tyarlupm5xzq5tt
+++ b/storage/innobase/trx/trx0trx.c revid:marko.makela@stripped937-pm3x5j1i846m4kog
@@ -207,45 +207,11 @@ trx_free(
/*=====*/
trx_t* trx) /*!< in, own: trx object */
{
- if (UNIV_UNLIKELY(trx->declared_to_be_inside_innodb)) {
- ut_print_timestamp(stderr);
- fputs(" InnoDB: Error: Freeing a trx which is declared"
- " to be processing\n"
- "InnoDB: inside InnoDB.\n", stderr);
- trx_print(stderr, trx, 600);
- putc('\n', stderr);
-
- /* This is an error but not a fatal error. We must keep
- the counters like srv_conc_n_threads accurate. */
- srv_conc_force_exit_innodb(trx);
- }
-
- if (UNIV_UNLIKELY(trx->n_mysql_tables_in_use != 0
- || trx->mysql_n_tables_locked != 0)) {
-
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: MySQL is freeing a thd\n"
- "InnoDB: though trx->n_mysql_tables_in_use is %lu\n"
- "InnoDB: and trx->mysql_n_tables_locked is %lu.\n",
- (ulong)trx->n_mysql_tables_in_use,
- (ulong)trx->mysql_n_tables_locked);
- trx_print(stderr, trx, 600);
- ut_print_buf(stderr, trx, sizeof(trx_t));
- putc('\n', stderr);
- }
-
ut_a(trx->magic_n == TRX_MAGIC_N);
-
- trx->magic_n = 11112222;
-
- ut_a(trx->state == TRX_STATE_NOT_STARTED);
+ ut_ad(!trx->in_trx_list);
mutex_free(&trx->undo_mutex);
- ut_a(trx->insert_undo == NULL);
- ut_a(trx->update_undo == NULL);
-
if (trx->undo_no_arr != NULL) {
trx_undo_arr_free(trx->undo_no_arr);
}
@@ -267,8 +233,6 @@ trx_free(
mem_heap_free(trx->global_read_view_heap);
}
- ut_a(trx->read_view == NULL);
-
ut_a(ib_vector_is_empty(trx->autoinc_locks));
/* We allocated a dedicated heap for the vector. */
ib_vector_free(trx->autoinc_locks);
@@ -289,6 +253,39 @@ trx_free_for_background(
/*====================*/
trx_t* trx) /*!< in, own: trx object */
{
+ if (UNIV_UNLIKELY(trx->declared_to_be_inside_innodb)) {
+ ut_print_timestamp(stderr);
+ fputs(" InnoDB: Error: Freeing a trx which is declared"
+ " to be processing\n"
+ "InnoDB: inside InnoDB.\n", stderr);
+ trx_print(stderr, trx, 600);
+ putc('\n', stderr);
+
+ /* This is an error but not a fatal error. We must keep
+ the counters like srv_conc_n_threads accurate. */
+ srv_conc_force_exit_innodb(trx);
+ }
+
+ if (UNIV_UNLIKELY(trx->n_mysql_tables_in_use != 0
+ || trx->mysql_n_tables_locked != 0)) {
+
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Error: MySQL is freeing a thd\n"
+ "InnoDB: though trx->n_mysql_tables_in_use is %lu\n"
+ "InnoDB: and trx->mysql_n_tables_locked is %lu.\n",
+ (ulong)trx->n_mysql_tables_in_use,
+ (ulong)trx->mysql_n_tables_locked);
+ trx_print(stderr, trx, 600);
+ ut_print_buf(stderr, trx, sizeof(trx_t));
+ putc('\n', stderr);
+ }
+
+ ut_a(trx->state == TRX_STATE_NOT_STARTED);
+ ut_a(trx->insert_undo == NULL);
+ ut_a(trx->update_undo == NULL);
+ ut_a(trx->read_view == NULL);
+
trx_free(trx);
}
@@ -308,37 +305,10 @@ trx_free_prepared(
ut_a(trx->magic_n == TRX_MAGIC_N);
trx_undo_free_prepared(trx);
-
- mutex_free(&trx->undo_mutex);
-
- if (trx->undo_no_arr) {
- trx_undo_arr_free(trx->undo_no_arr);
- }
-
- ut_a(trx->lock.wait_lock == NULL);
- ut_a(trx->lock.wait_thr == NULL);
-
- ut_a(!trx->has_search_latch);
-
- ut_a(trx->dict_operation_lock_mode == 0);
-
- if (trx->lock.lock_heap) {
- mem_heap_free(trx->lock.lock_heap);
- }
-
- ut_a(UT_LIST_GET_LEN(trx->lock.trx_locks) == 0);
-
- if (trx->global_read_view_heap) {
- mem_heap_free(trx->global_read_view_heap);
- }
-
- ut_a(ib_vector_is_empty(trx->autoinc_locks));
- ib_vector_free(trx->autoinc_locks);
-
+ ut_ad(trx->in_trx_list);
+ ut_d(trx->in_trx_list = FALSE);
UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
-
- mutex_free(&trx->mutex);
- mem_free(trx);
+ trx_free(trx);
}
/********************************************************************//**
Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20110418110937-pm3x5j1i846m4kog.bundle
| Thread |
|---|
| • bzr push into mysql-trunk-innodb branch (marko.makela:3590 to 3591)Bug#11833462 | marko.makela | 18 Apr |