Ciao Marcello,
Thanks for the detailed report: this is a real bug, not intended behavior.
LOCAL is a documented (if rarely used) synonym for SESSION in MySQL's SET syntax.
Worth noting MySQL itself doesn't even list LOCAL in the syntax diagram on its own docs page:
It only mentions it as an aside, which is probably why it slipped through our variable-tracking/query-classification logic.
SET SESSION is correctly recognized and tracked; SET LOCAL is not, and incorrectly falls back to locking the connection to the current hostgroup.
Feel free to follow/subscribe there for updates.
Thanks again for the clear repro, it made this easy to confirm.
Grazie!