This topic contains 2 replies, has 2 voices, and was last updated by  Ian Hay 9 years, 3 months ago. Usage

  • I have a number of translator scripts that connect to a database to do some work. Unfortunately we’ve been having some late night instability which means the second these scripts fail due to connectivity issues with SQL the channel just stops, so it means our critical channels get backlogged until someone restarts them, usually first thing in the morning.

    To get around this I put the database calls into a function, which has now fixed our problem nicely, it’ll keep trying and eventually kick back into gear once the connection is established again. I’ve hit one minor issue with it though, and that is around troubleshooting issues when the database does go down during work hours.

    Below is an example error message that is being generated when it’s using

    Error connecting to database. Retrying (29 of 30 in 10 seconds)… Delayed 280 seconds…

    If I then remove the and run it again I get the real issue presented (I’ve removed database names on purpose):

    ODBC Error:
    [Microsoft][ODBC SQL Server Driver][SQL Server]Could not allocate space for object ‘dbo’.’IX_’ in database ‘db_’ because the ‘PRIMARY’ filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.

    The code I’m running is below, I’m curious as to how I can use the and still display the actual database error to simplify troubleshooting issues as they arise:

    function main(Data)   
       iguana.logDebug("*** Processing Message: "..Data.." ***")   
       local T, ScriptSuccess = MapData(Data)     
       if T and ScriptSuccess then      
{func=SendToDB, arg1=T, retry=30, pause=10}   
    function SendToDB(T)   
       db.merge{api=db.SQL_SERVER,name=ODBCConnection.ODBC, user=ODBCConnection.UserName, password=ODBCConnection.Password, data=T}

    The retry module uses pcall to do it’s thing:

    You can see the error message get’s returned from pcall so you could tweak the retry module to log the error and give you visibility on the problem.

    Easier than I expected :), thanks for that. I just added R[2] to the end of the line below in the retry module:

    local E = 'Error connecting to database. Retrying ('..i..' of '..RetryCount..' in '..Delay..' seconds)... Delayed '..TotalWaitTime..' seconds...\n\nError Details: '..R[2]      
    iguana.setChannelStatus{color='yellow', text=E}

You must be logged in to reply to this topic.