Skip to main content
Known Participant
June 25, 2020
Question

CFTRANSACTION not working anymore in our environment

  • June 25, 2020
  • 2 replies
  • 623 views

Greetings,

 

I just discovered based on incomplete recording in PROD database that CFTRANSACTION tag is not working anymore. Not sure if that specific to our environment or global issue.  Don't know if CF upgade or MS SQL upgrade caused that.. I know that it was working in CF11 environment, we have switched to CF18 about a year and half ago. 

 

My environment:

ColdFusion 2018 

Version 2018.0.09.318650

Edition- developer(but it doesn't work in enteprize also)

Microsoft SQL Server Enterprise
Platform NTx64
Version 13.0.5081.1

 

Example of simple test code below:

 

<cftransaction  action="begin" >

<cfquery name="Test1" datasource="XXX">
INSERT INTO TrTest1 (TestString)
VALUES('Recording 1')
</cfquery>

<cfquery name="Test2" datasource="XXX">
INSERT INTO TrTest2 (TestString)
VALUES('Recording 2')
</cfquery>

 

<cftransaction action="rollback" />

 

Rollback is not working, records are inserted Can anybody verfy that or point if that simple test case incorrect. It is pretty much a disaster. I hope it is connected with some setting for MS SQL.

 

Regards,

Simon Litvak

UC Berkeley

 

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    June 25, 2020

    Hmmm, I'm not sure how that would work. Were you perhaps aiming for something like the following?

    <!--- Experiment with true, then with false, and see what happens --->
    <cfset isRolledBack=true>
    
    <cftransaction>
    
    <cfquery name="Test1" datasource="XXX">
    INSERT INTO TrTest1 (TestString)
    VALUES('Recording 1')
    </cfquery>
    
    <cfquery name="Test2" datasource="XXX">
    INSERT INTO TrTest2 (TestString)
    VALUES('Recording 2')
    </cfquery>
    
    <cfif isRolledBack>
            <!--- Nested transaction --->
    	<cftransaction action="rollback" />
    </cfif>
    
    </cftransaction>
    
     
    SimonGSWAuthor
    Known Participant
    June 25, 2020

    Hi BKBK,

     

    I think, that is not going to have any difference with my code.  I just have uncoditional rollback.

     

    Regards,

    Simon

    Community Expert
    June 25, 2020

    I think you do need to post a more complete code sample, as your original one shouldn't really work at all. CFTRANSACTION requires an opening and a closing tag, you can't just have one CFTRANSACTION tag at the top and another later on doing a rollback. At least, it's not supposed to work that way. Maybe it did before, but ... it wasn't supposed to.

     

    Dave Watts, Eidolon LLC

    Dave Watts, Eidolon LLC
    Community Expert
    June 25, 2020

    What's the transaction isolation level in both old and new database environments?

     

    Dave Watts, Eidolon LLC

    Dave Watts, Eidolon LLC
    SimonGSWAuthor
    Known Participant
    June 25, 2020

    Hi Dave,

     

    I didn't specified isolation level in my CFTRANSACTION. So is your question about MS SQL settings?  If yes, I need to contact DBA. I don't manage databases.

     

    Regards,

    Simon

    Community Expert
    June 25, 2020

    Yeah, you should definitely know what the default transaction isolation level is in your databases. Otherwise, you can't really be sure what CFTRANSACTION is going to do! Usually, it's "read committed" I think for SQL Server.

     

    Dave Watts, Eidolon LLC

    Dave Watts, Eidolon LLC