Android Question RDC2_Handler error

marcick

Well-Known Member
Licensed User
Longtime User
I often register this error in sub Handle of RDCHandler

B4X:
2017-06-09 10:47:44 - RDCHandler_Handle error, (TimeoutException) com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@15975490 -- timeout at awaitAvailable()

This is the sub

B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
    Start = DateTime.Now
    Dim q As String     'ignore
    Dim in As InputStream = req.InputStream
    Dim method As String = req.GetParameter("method")
    Dim con As SQL
    Try
        con = Main.rdcConnector1.GetConnection
        If method = "query2" Then
            q = ExecuteQuery2(con, in, resp)
#if VERSION1
        Else if method = "query" Then   
            in = cs.WrapInputStream(in, "gzip")
            q = ExecuteQuery(con, in, resp)
            'Log($"Command: ${q}, tool: ${DateTime.Now - Start}ms, client=${req.RemoteAddress}"$)
        Else if method = "batch" Then
            in = cs.WrapInputStream(in, "gzip")
            q = ExecuteBatch(con, in, resp)
            'Log($"Command: ${q}, tool: ${DateTime.Now - Start}ms, client=${req.RemoteAddress}"$)
#end if
        Else if method = "batch2" Then
            q = ExecuteBatch2(con, in, resp)
        Else
            Log("Unknown method: " & method)
            resp.SendError(500, "unknown method")
        End If
    Catch
        Log("RDCHandler_Handle error, " & LastException)
        resp.SendError(500, LastException.Message)
        If LastException.Message.Contains("0000-00-00 00:00:00") Then PurgeBadRecord   
        Dim TextWriter1 As TextWriter
        TextWriter1.Initialize(File.OpenOutput(File.DirApp, "Restart.log",True))
        TextWriter1.Write(DateTime.date(DateTime.Now) & " - RDCHandler_Handle error, " & LastException)
        TextWriter1.Close
        Main.robot.relaunchSelfbatch("jrdc.bat")
    End Try
    If con <> Null And con.IsInitialized Then con.Close   
End Sub

Any idea ?
 

DonManfred

Expert
Licensed User
Longtime User
With 3 indexes in the db all works perfect in a few mS for each query.
Always make sure to set indexes to fields you use in a WHERE.
Recheck your queries from time to time using explain to find missing indexes

Using the right Indexes is the essence of a fast Database...
 
Upvote 0
Top