public HandleErrorResult relaunchOperation ( Method method , Object [ ] args ) throws IllegalAccessException , InvocationTargetException { HandleErrorResult handleErrorResult = new HandleErrorResult ( true ) ; if ( method != null ) { switch ( method . getName ( ) ) { case "executeQuery" : if ( args [ 2 ] instanceof String ) { String query = ( ( String ) args [ 2 ] ) . toUpperCase ( Locale . ROOT ) ; if ( ! "ALTER SYSTEM CRASH" . equals ( query ) && ! query . startsWith ( "KILL" ) ) { logger . debug ( "relaunch query to new connection {}" , ( ( currentProtocol != null ) ? "(conn=" + currentProtocol . getServerThreadId ( ) + ")" : "" ) ) ; handleErrorResult . resultObject = method . invoke ( currentProtocol , args ) ; handleErrorResult . mustThrowError = false ; } } break ; case "executePreparedQuery" : //the statementId has been discarded with previous session try { boolean mustBeOnMaster = ( Boolean ) args [ 0 ] ; ServerPrepareResult oldServerPrepareResult = ( ServerPrepareResult ) args [ 1 ] ; ServerPrepareResult serverPrepareResult = currentProtocol . prepare ( oldServerPrepareResult . getSql ( ) , mustBeOnMaster ) ; oldServerPrepareResult . failover ( serverPrepareResult . getStatementId ( ) , currentProtocol ) ; logger . debug ( "relaunch query to new connection " + ( ( currentProtocol != null ) ? "server thread id " + currentProtocol . getServerThreadId ( ) : "" ) ) ; handleErrorResult . resultObject = method . invoke ( currentProtocol , args ) ; handleErrorResult . mustThrowError = false ; } catch ( Exception e ) { //if retry prepare fail, discard error. execution error will indicate the error. } break ; default : handleErrorResult . resultObject = method . invoke ( currentProtocol , args ) ; handleErrorResult . mustThrowError = false ; break ; } } return handleErrorResult ; }
After a failover that has bean done relaunch the operation that was in progress . In case of special operation that crash server doesn t relaunched it ;