intermittent stored function "does not exist" problem

We use a database running on percona server 5.6.28 (under ubuntu), which has a large number of stored procedures and functions (around 2000 procedures and 600 functions). A few weeks ago (after the number of stored functions had been significantly increased) the calling application started getting messages saying that functions did not exist (we verified that they did actually exist.) There were no updates to, or reconfigurations of, either percona or the underlying ubuntu system at the same time that the problem started happening.

Restarting percona made the problem go away for a while. Eventually we tried increasing stored_program_cache to 600, and this seems to have cured the problem (at least for the time being.)

I searched for a long time on the web, and had great difficulty finding anything relevant. The only things which I could find (apart from obvious user errors) were related to case-sensitivity issues, and we verified that (to the best of our belief) these are not applicable in our case. Eventually, I decided to look at the code, and found something which seemed strange: I noticed that there were some calls to sp_find_routine() which apparently told it not to check mysql.proc if the requested stored procedure or function was not found in the cache, and just to return a “does not exist” error. I know I’m clutching at straws (particularly as no one else seems to be experiencing this) - but this did seem to suggest what we have been seeing (and there don’t seem to be any other obvious possible causes.)

I’d be grateful for any thoughts on this.

Sporadically, we have the same issue.

I have the feeling that this is caused by connection pooling in combination with queries changing the “max_heap_table_size” (to a huge size) but do not reset that value. The session seems to run out of memory for lookup of routines (stored functions or -procedures).

As of now this is just an assumption. Did someone experience the same behaviour?