Bug #74681 Speed up fsp_get_available_space_in_free_extents()
Submitted: 4 Nov 2014 13:30 Modified: 5 Nov 2014 17:41
Reporter: Marko Mäkelä Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7.6 OS:Any
Assigned to: CPU Architecture:Any

[4 Nov 2014 13:30] Marko Mäkelä
Description:
The function fsp_get_available_space_in_free_extents() is accessing the first page of the tablespace in the buffer pool, potentially causing I/O especially on tablespaces that are rarely written to.

We could get the metadata directly from the fil_space_t object if we cached the data whenever the page is modified.

How to repeat:
Read the code.

Suggested fix:
Whenever a tablespace header page is accessed, check with debug assertions that fil_space_t is in sync with the data.
Whenever a tablespace header page is modified, modify the corresponding fil_space_t fields.
[5 Nov 2014 17:41] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.7.6 release, and here's the changelog entry:

To avoid I/O on tablespaces that are rarely written to, the
"fsp_get_available_space_in_free_extents" function now accesses metadata
from cached fields instead of the tablespace header page in the buffer
pool. 

This patch also includes the following optimizations:

To avoid lookups, "fsp_fill_free_list()" and some other
functions now take a "fil_space_t" pointer instead of a numeric tablespace
identifier. 

The "fil_extend_space_to_desired_size"
function is renamed to "fil_space_extend" and its API is simplified.

A new method, "undo::Truncate::was_tablespace_truncated", is added to avoid a
consistency check before flushing of truncated undo tablespace files.