I use Patterns.ask() way to send a message to xxActor and use Await.result() way to set timeout.
when the xxActor onReceive the message, it will do something and update Mysql table data.
for some reason,xxActor not finished,but timeout,so Await.result() throw exception:“Futures timed out”
and result in mysql table lock
how to deal with the situation?
You should never use Await
inside of an actor. Use the pipe pattern to pipe the completed future back to the actor (or to some other actor) instead: https://doc.akka.io/docs/akka/current/futures.html#use-the-pipe-pattern . Ask itself already has a timeout and the response future will be failed if that timeout hits.