The following example SQL demonstrates the problem when executed through readwritesplit.
The last statement should be routed as an autocommit read but it is treated as if autocommit was still disabled.
This is caused by a bug in an optimization for the transaction tracking code that reuses the query classification result instead of parsing the query multiple times. Due to the query classification cache, the canonical form of both autocommit statements would be SET autocommit=? and they would both be classified as the query type that first arrived. The solution is to never insert these types of queries into the cache.