Worker.gatherStats() runs a "analyze table..." command to update stats which requires SessionState. SessionState objects are cached in ThreadLocal. If for some reason Session init fails, it may still get attached to the thread which then causes a subsequent request that uses the same thread to gather stats fail because it has a bad session object. HIVE-15658 describes the same issue in a different context.
There is currently no way to recycle a session from outside HMS.
Failure to gather stats should not kill a compaction job which then prevents Cleaner from running.