Bug #30712 open_performance_schema_table() cause an open table leak on failures
Submitted: 30 Aug 2007 0:00 Modified: 9 Oct 2007 0:43
Reporter: Marc Alff Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S2 (Serious)
Version:5.1 OS:Any
Assigned to: Marc Alff CPU Architecture:Any

[30 Aug 2007 0:00] Marc Alff
Description:
Found by code review.

In Log_to_csv_event_handler::log_slow and ::log_general,
calls to:
- open_performance_schema_table()
- close_performance_schema_table()
are not paired anymore due to a recent code change,
so that the net effect is that

  thd->restore_backup_open_tables_state(backup);
is not called anymore on failures in open.

The impact is that when a query opens tables then fails to open log tables,
the tables opened by the query are never closed.

How to repeat:
Code review

Suggested fix:
Either
a) match calls to open and close,
b) have open() cleanup on failures and call 
  thd->restore_backup_open_tables_state(backup);
and change all the existing calls to open/close performance_schema_table

b) is preferred, to avoid the cost of LOCK_open which is not needed:
this would improve the performance in degraded modes (logging to tables turned on, but logging fails)
[30 Aug 2007 0:57] 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/33413

ChangeSet@1.2585, 2007-08-29 18:56:00-06:00, malff@weblab.(none) +2 -0
  Bug#30712 (open_performance_schema_table() cause an open table leak on
  failures)
  
  Fixed open_performance_schema_table() and close_performance_schema_table()
  implementation and callers, to always execute balanced calls to:
    thd->reset_n_backup_open_tables_state(backup);
    thd->restore_backup_open_tables_state(backup);
[7 Sep 2007 8:09] Bugs System
Pushed into 5.1.23-beta
[9 Oct 2007 0:43] Paul Dubois
No user-visible changes. No changelog entry needed.