Bug #76060 open and close of Instrinsic table causes negative MONITOR_TABLE_REFERENCE count
Submitted: 26 Feb 2015 11:30 Modified: 4 Mar 2015 17:35
Reporter: Naga Satyanarayana Bodapati Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[26 Feb 2015 11:30] Naga Satyanarayana Bodapati
Description:
When instrinsic tables are opened & closed, they cause negative table ref count in monitor output

How to repeat:
I've verified from gdb.

1) intrinsic table open doesn't go via normal dictionary cache. So, no dict_open_on_id()/name()
2) So the table ref count is not incremented
3) But the table close operation goes via dict_table_close() which decrements MONITOR_TABLE_REFERENCE

Suggested fix:
Krunal suggested the fix on IM:

infact we need to skip the dec action 
(04:36:44 PM) krunal.bauskar:         --table->n_ref_count;

        /* Force persistent stats re-read upon next open of the table
        so that FLUSH TABLE can be used to forcibly fetch stats from disk
        if they have been manually modified. We reset table->stat_initialized
        only if table reference count is 0 because we do not want too frequent
        stats re-reads (e.g. in other cases than FLUSH TABLE). */
        if (strchr(table->name.m_name, '/') != NULL
            && table->n_ref_count == 0
            && dict_stats_is_persistent_enabled(table)) {

                dict_stats_deinit(table);
        }

        MONITOR_DEC(MONITOR_TABLE_REFERENCE);

        /* Intrinsic table is not added to dictionary table list
        so skip the next section that try to do that. */
        if (dict_table_is_intrinsic(table)) {
                return;
        }
[4 Mar 2015 17:35] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.7.6, 5.8.0 releases, and here's the changelog entry:

Opening and closing of intrinsic temporary tables resulted in a negative
table reference count in "InnoDB" Monitor output. 

Thank you for the bug report.