• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cfthread not working (New upgrade to CF 2018 std)

Community Beginner ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

Hi,

I installed a new server (Win 2012 R2 / IIS) to migrate an old CF10 server to the new CF2018 version. Problem is cfthreads are not executing on CF2018.

For testing purposes I setup a simple page as follows:

======================================

INSERT INTO TABLE (record1)

<cfthread action="RUN" name="Test_Thread">

    INSERT INTO TABLE (record2)

</cfthread>

INSERT INTO TABLE (record3)

======================================

Records #1 & #3 get inserted, but not record #2.

Log shows:

application.log = "Error","cfthread-1","11/29/18","16:02:42","","TEST_THREAD: coldfusion/runtime/CFPage".

cf-out.log = Nov 29, 2018 16:02:42 PM Error [cfthread-1] - TEST_THREAD: coldfusion/runtime/CFPage

exception.log = Caused by: java.lang.ClassNotFoundException: coldfusion.runtime.CFPage

Couldn't find any info on this.

Any suggestion?

Thanks!

Views

641

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Feb 06, 2019 Feb 06, 2019

This have been puzzling me for the past few months trying to isolate the cause. I didn't want to reinstall because of we had so many configured DSN's, schedules, etc. I should have known better! Yesterday I gave up troubleshooting and decided to remove CF2018 and re-install. Problem Solved!!!!!

Now cfthread works as expected on MySQL 5.7 and MySQL 8.0; when previously cfthread only worked on non-odbc calls. When I first installed, I never received an error/alert; so this will be an solved/unsolve

...

Votes

Translate

Translate
Community Expert ,
Dec 01, 2018 Dec 01, 2018

Copy link to clipboard

Copied

Could you show us the code you used. I strongly suspect it needs to be corrected.

I tested the following code on a database table named tbl (having 2 columns, of type date and UUID):

<cfset sql1="INSERT INTO tbl VALUES(#now()#,'#createuuid()#')">

<cfset queryExecute(sql1, {}, {datasource="myDSN"})>

<cfthread action="RUN" name="Test_Thread">

   <cfset sql2="INSERT INTO tbl VALUES(#dateAdd('d',1,now())#,'#createuuid()#')">

   <cfset queryExecute(sql2, {}, {datasource="myDSN"})>

</cfthread>

<cfset sql3="INSERT INTO tbl VALUES(#dateAdd('d',2,now())#,'#createuuid()#')">

<cfset queryExecute(sql3, {}, {datasource="myDSN"})>

It works as expected. Nevertheless, sometimes the insert in the thread is done last. But, then again, that is what you would expect of asynchronous threads.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2018 Dec 02, 2018

Copy link to clipboard

Copied

If you're inserting into the same table within the CFTHREAD that you're inserting into before and after, I'm not surprised that you're having problems. Databases usually require some way to handle transactions so that they don't mess up other transactions. In some databases, this is handled by locking. So, the first query would place an exclusive lock on the table, the second query would run in a second thread (concurrently, not serially) and the third query would again require an exclusive lock on the same table. In a single program, this is usually not a problem because the queries would be handled serially. There are all kinds of potential complications here, as well: what is the transaction isolation level, etc, etc.

Dave Watts, Fig Leaf Software

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 04, 2019 Feb 04, 2019

Copy link to clipboard

Copied

More info about this issue... It's apparently an issue with MySQL 8 support. If I setup the same DSN w/ MySQL 5.7 instead of MySQL 8.0 the cfthread works as expected.

I can connect and execute DB Commands (like Inserts/updates) on MySQL 8 using the mysql-connector-java-8.0.12.jar. This works flawlessly on any .CFM page; even with a query inside a cfinclude. But as soon as I place the cfquery inside a cfthread tag nothing happens I get the log error on the OP.

The same example as above but using a DSN on MySQL 5.7 works without issues.

Can anyone with CF2018 & MySQL8.0 confirm?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 04, 2019 Feb 04, 2019

Copy link to clipboard

Copied

Now it get weirder. I was able to make it work if I use a cfinclude inside the cfthread like this:

thrpage.cfm

=============================================

<cfthread action="run" name="THR1">

    <cfinclude template="action.cfm">

</cfthread>

=============================================

action.cfm

=============================================

<cfquery name="QR1" datasource="mydsn" dbtype="ODBC">

INSERT INTO TBL1 (field1) VALUES ('ok')

</cfquery>

=============================================

But that only works if I first call the stand alone page "action.cfm" before any subsequent calls to "thrpage.cfm". This will continue to work until I edit the "action.cfm" page. As soon as I edit that page the cfthread stops working. Any edit like adding a space or character to the end of the page will not allow subsequent chthreads on the "thrpage.cfm" until I re-execute the "action.cfm" on the browser.

I suspect this could be a cache issue. But even restarting the server will not make it work. Only calling the "action.cfm" page first seams to solve the issue; unless that page is edited.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2019 Feb 04, 2019

Copy link to clipboard

Copied

It think it is sufficient to run just thrpage.cfm alone. If you run action.cfm followed by thrpage.cfm you will be doing the insert twice.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 05, 2019 Feb 05, 2019

Copy link to clipboard

Copied

Problem is that:

  1. I run "thrpage.cfm" (w/ cfinclude "action.cfm" inside cfthread) NO INSERT will happen.
  2. if I run "action.cfm" 1 INSERT will happen.
  3. If now I run "thrpage.cfm" 1 INSERT will happen for every time I reload/access the page.
  4. If I edit "action.cfm" and add a character or space to the file & save:
  5. Now I run "thrpage.cfm" NO INSERT will happen (ever) until I go to step #2.

This happens on MySQL 8.0 & 5.7. I have tried to enable/disable cache features at no avil.

As last resort, I'll try to uninstall and reinstall CF2018

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2019 Feb 05, 2019

Copy link to clipboard

Copied

Then there is something else wrong with your system. The reason I say that is as follows.

To test your code, I created

testpage1.cfm

<cfthread action="run" name="THR1">

    <cfinclude template="testpage2.cfm">

</cfthread>

testpage2.cfm

<cfquery name="QR1" datasource="test_db" dbtype="ODBC">

INSERT INTO birds (id,name) VALUES (10,'Bird-of-paradise')

</cfquery>

When I opened testpage1.cfm in the browser, the insert-query ran successfully. In any case. 1 attribute is sufficient for an insert:

<cfquery datasource="test_db">

INSERT INTO birds (id,name) VALUES (10,'Bird-of-paradise')

</cfquery>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

LATEST

This have been puzzling me for the past few months trying to isolate the cause. I didn't want to reinstall because of we had so many configured DSN's, schedules, etc. I should have known better! Yesterday I gave up troubleshooting and decided to remove CF2018 and re-install. Problem Solved!!!!!

Now cfthread works as expected on MySQL 5.7 and MySQL 8.0; when previously cfthread only worked on non-odbc calls. When I first installed, I never received an error/alert; so this will be an solved/unsolved mystery...

Thanks to all for your suggestions!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation