tracker issue : CF-4198513

select a category, or use search below
(searches all categories and all time range)
Title:

Query Caching with cachedwithin = 0

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Jay Kirk / Jay Kirk ()

Created: 04/12/2017

Components: Caching

Versions: 2016

Failure Type: Non Functioning

Found In Build/Fixed In Build: ColdFusion 2016 Update 3 / 303574

Priority/Frequency: Normal / All users will encounter

Locale/System: English / Windows 10 64 bit

Vote Count: 3

Listed in the version 2016.0.05.303689 Issues Fixed doc
Problem Description: I just recently switched my developer environment to ColdFusion 2016.  We were previously running ColdFusion 11.  We cache queries using the query tag cachedwithin.  When we update the database, and rerun the query with a cachedwithin timespan of 0, ColdFusion 11 updates the cache and has the current data.  In ColdFusion 2016, the query returns the current data, however, the cache is not updated as well.  If you go to another page, or refresh the current page, that uses the same query cache, the data is no longer updated.

Steps to Reproduce:  1. Cache a query with cachedwithin="#CreateTimeSpan(0, 1, 0, 0)#".  2. Update the database, rerun the query with cachedwithin="#CreateTimeSpan(0, 0, 0, 0)#".  Reload the page with the query with cachedwithin="#CreateTimeSpan(0, 1, 0, 0)#".  Results will be old data.

Actual Result:  Old data  returned with old cache.

Expected Result:  New data returned.

Any Workarounds:Run the cacheRemove function on the query id.

Attachments:

  1. August 08, 2017 00:00:00: 20170807_4198513.zip

Comments:

Example code: <cfquery name="loc.getInfo" datasource="myDB" timeout="5" cacheid="myQ" cachedwithin="#CreateTimeSpan(0, 1, 0, 0)#"> SELECT * FROM INFO WHERE ID = 1 </cfquery> <cfdump var=loc.getInfo /> <cfquery datasource="myDB"> UPDATE INFO SET Name = 'New Name' WHERE ID = 1 </cfquery> <cfquery name="loc.getInfo" datasource="myDB" timeout="5" cacheid="myQ" cachedwithin="#CreateTimeSpan(0, 0, 0, 0)#"> SELECT * FROM INFO WHERE ID = 1 </cfquery> <cfdump var=loc.getInfo /><!--- this is correct ---> <cfquery name="loc.getInfo" datasource="myDB" timeout="5" cacheid="myQ" cachedwithin="#CreateTimeSpan(0, 1, 0, 0)#"> SELECT * FROM INFO WHERE ID = 1 </cfquery> <cfdump var=loc.getInfo /><!--- this is incorrect --->
Comment by Jay K.
940 | April 12, 2017 10:31:30 PM GMT
Using ColdFusion 3, 4, 5, 6, 7, 8, 9, 10, 11 and Railo/Lucee, using CachedWithin=0 was the method to refresh a cached query. This looks like it may be bug CF-4170628 which was reported on 7/5/2016 with a status of "fixed". I don't want to have to add cacheIDs and cacheRemove functions all over my code to account for this new CF2016 bug.
Vote by James M.
946 | July 05, 2017 02:04:41 PM GMT
Hi Adobe, This ticket's "Failure Type" should be "Data Corruption". Also, here's another repro case: <cfscript> q1 = queryNew("foobar", "", [["foo"]]); q2 = queryExecute("SELECT foobar FROM q1", [], {dbtype="query", cachedWithin=createTimeSpan(0,0,1,0)});//returns cached query (good) q1.setCell("foobar", "bar", 1); q3 = queryExecute("SELECT foobar FROM q1", [], {dbtype="query", cachedWithin=createTimeSpan(0,0,0,0)});//returns non-cached query (good) writeOutput(q3.foobar); q4 = queryExecute("SELECT foobar FROM q1", [], {dbtype="query", cachedWithin=createTimeSpan(0,0,1,0)});//returns _original_ cached query (bad) writeOutput(q4.foobar);//CF2016 Update 1 and 3 return "foo" (bad). CF11 returns "bar" (good). </cfscript> Thanks!, -Aaron
Comment by Aaron N.
941 | July 11, 2017 09:28:37 PM GMT
+1 - After filing CF-4170628, I simply didn't test further to find this issue. I no longer use(d) cached queries in CF2016. Use of cached queries in CF2016 can cause data corruption. Spread the word. Have a Public Beta for Aether.
Vote by Aaron N.
947 | July 11, 2017 09:31:20 PM GMT
Attached 20170807_4198513.zip, containing repros that can be ran in CF10/CF11/CF2016. They show createTimeSpan(0,0,0,0) correctly clears the cache in CF10 and CF11 but not in CF2016. Thanks! -Aaron
Comment by Aaron N.
942 | August 08, 2017 03:21:04 AM GMT
Hi Adobe, Could you please attach the patch? So we can test it. Thanks!, -Aaron
Comment by Aaron N.
943 | August 15, 2017 09:26:39 PM GMT
Aron: Please find attached the patch for this. [^QueryCaching.jar]
Comment by Ashudeep S.
944 | August 16, 2017 06:43:03 AM GMT
This issue is fixed now. The fix will be available as part of an upcoming update of ColdFusion 2016.
Comment by Nimit S.
945 | August 21, 2017 04:55:40 PM GMT