Skip to main content
Participating Frequently
April 15, 2015
Question

How can I manage CF hanging when waiting for release of a lock held by 2nd Application on same datasource?

  • April 15, 2015
  • 1 reply
  • 2111 views

My CF application links to the MS SQL database of my accounting application.

If a specific record is being edited in the accounting application and I try to update that specific record using the coldfusion application, the coldfusion system hangs until the accounting application releases the record.

This is fine except the user in the accounting application may have left the editing screen open and the record may not be released for minutes or longer. Once this is the case the hanging coldfusion request creates further locks.

How can I manage the situation so that I can send a message to the user that they cannot gain exclusive access to the record and so cannot update it until the record is free thus preventing the hanging situation which escalates the problem?

Regards

Richard

    This topic has been closed for replies.

    1 reply

    Legend
    April 15, 2015

    You could try a call to the datasource within a CFTRY and a specific timeout setting.  If the timeout is hit, most like due to being locked out of the datasource, then inform the user in the CFCATCH.

        

         <cftry>

              <cfsetting requestTimeout="100">

                <cfquery datasource="#MyDSN#" name="test">

                    SHOW TABLES;

                </cfquery>

                <cfcatch type="any">

                    Sorry, the datasource is not available.

                </cfcatch>

            </cftry>

    rdipAuthor
    Participating Frequently
    April 15, 2015

    The transaction is already within a <cftransaction> with a <cftry> and <cfcatch> - see simplified version below. If anything is caught by the cfcatch then the process should stop and an error be given.

    However when the lock occurs, there is no error reported, it just hangs. When the lock is released there is a general timeout error rather than an error caught by the <cftry> and <cfcatch>

    <cfset queries_completed=1> 

    <cftransaction><!--- this is to make all the updates as one transaction which either completes or fails--->   

    <cftry><!--- this is for error catching if any of the queries fail - errors will be caught lower down by cfcatch tag --->

    <cfquery name="update_customer" datasource="#request.odbc_datasource#">       

               Update scheme.slcustm
               SET control_digit='#control_digit#'
               where customer='#customer_id#'       

      </cfquery>

           

    <cfcatch> <!--- catch any error and perform actions below--->

    <cfset queries_completed=0>

    <cftransaction action="rollback"><!--- reverses above queries --->

    <p>This transaction failed ! Error Type: <cfoutput>#cfcatch.type#</cfoutput></p>

    <p><cfoutput>#cfcatch.message#</cfoutput></p>

    <p><cfoutput>#cfcatch.detail#</cfoutput></p>

    <cfoutput>

    <p><a href="javascript:history.back()">Go back to amend</a></p>

    </cfoutput>

    <cfabort>

    </cfcatch>

    </cftry>

    <cfif queries_completed is 1>

    <cftransaction action="commit">

    </cfif>

    </cftransaction><!--- end of transaction --->

    Regards

    Richard

    rdipAuthor
    Participating Frequently
    April 15, 2015

    Some more detail - I did try the cfsetting as above but made no difference to the end result. The system hangs until the lock is released and then reports a timeout error of the query and a timeout error on the output in the <cfcatch> tag

    14:36:19.019 - Application Exception - in C:/ColdFusion11/cfusion/wwwroot/sagelink_diaries/sales/call_contact_2.cfm : line 117

             The request has exceeded the allowable time limit Tag: CFQUERY 

    14:36:20.020 - coldfusion.util.RuntimeWrapper Exception - in C:/ColdFusion11/cfusion/wwwroot/sagelink_diaries/sales/call_contact_2.cfm : line 271

             The request has exceeded the allowable time limit Tag: cfoutput 

    Regards

    Richard