There was a bug when SQL statistics LRU removed some old query from the _sql_query table. The query ref_counter field in unsigned, but the code decremented it below zero in the space on eviction. That produced an error (fixed).