Using thread_statistics does not clear state when a thread goes away

Bug #1580710 reported by colin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
New
Undecided
Unassigned

Bug Description

When running Percona Server 5.6.28-76.1 with thread_statistics=1 and userstat=1, I notice that memory constantly increases with each new connection (from basic calculations, ~400 bytes per connection).
In our case, applications recycle connections every 10 minutes or after N number of usages. Over time this will result in a large number of connections being used.

IMO the hash table (global_thread_stats) and the thread_statistics table should both remove the entry for a thread once the thread has died/gone away.

I reproduced this locally by continuously reconnecting a client and observed the RSS of mysqld.

Tags: userstat
tags: added: userstat
Revision history for this message
colin (coldeasy-hotmail) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

There are use cases for historical data in THREAD_STATISTICS, i.e. not all the users would appreciate data for disconnected connections disappearing at the same moment. On the other hand, keeping everything results in unbounded memory growth and is not desirable neither as you found. We could introduce an option to keep 10000 or a different number of most recent entries, but I'm not sure the implementation is suitable for such limit at the moment.

Does regular FLUSH THREAD_STATISTICS work for you as a workaround?

Revision history for this message
colin (coldeasy-hotmail) wrote :

Based a quick local test doing a FLUSH THREAD_STATISTICS reduces the memory growth substantially though not entirely - I guess due to the in-memory hash table?

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Each FLUSH destroys and re-creates the in-memory hash table. If you observe a memory use growth despite the periodic FLUSH, the root cause of that growth must be further researched.

Have you checked if there is no (small) continuous growth with your patch that clear thread data on disconnect?

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-3430

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.