Write-lock a whole table during transaction
The Slave should be irrelevant, unless you are using (misusing) some form of parallel execution on the Slave.

Try other transaction_isolation_modes.

GET_LOCK()/RELEASE_LOCK() may provide a sufficient "lock"; but all writers to that table(s) would need to use it.

Do not turn on auto-reconnect in your connection.  An network glitch will mess with both the transaction and GET_LOCK.