java.util.ConcurrentModification Exception with queryExecute + returntype:struct

java.util.LinkedHashMap$LinkedHashIterator.nextNode(Unknown Source)
java.util.LinkedHashMap$LinkedEntryIterator.next(Unknown Source)
java.util.LinkedHashMap$LinkedEntryIterator.next(Unknown Source)
lucee.runtime.type.StructImpl.copy(StructImpl.java:240)
lucee.runtime.type.query.QueryStruct.duplicate(QueryStruct.java:77)
lucee.runtime.cache.tag.query.QueryStructItem.duplicate(QueryStructItem.java:29)
lucee.runtime.op.Duplicator.duplicate(Duplicator.java:132)
lucee.runtime.cache.ram.RamCache.decouple(RamCache.java:276)
lucee.runtime.cache.ram.RamCache.getCacheEntry(RamCache.java:158)
lucee.runtime.cache.CacheSupport.getValue(CacheSupport.java:216)
lucee.runtime.cache.tag.timespan.TimespanCacheHandler.get(TimespanCacheHandler.java:65)
lucee.runtime.cache.tag.timespan.TimespanCacheHandler.get(TimespanCacheHandler.java:199)
lucee.runtime.tag.Query._doEndTag(Query.java:634)
lucee.runtime.tag.Query.doEndTag(Query.java:565)
lucee.runtime.functions.query.QueryExecute.call(QueryExecute.java:86)
sfmx_page_cfm$cf.call(/sfmx_page.cfm:59)

Cause is the query below, when in runs heavily concurrent on the live system (errors captured via FR):

queryExecute(
	"select top 1 id, foo from pages where id = ?",
	{{ value:id, cfsqltype:"integer" },
	{ cachedwithin:createTimeSpan(0,0,10,0), returntype:"struct" }
)

I assume the cache creates one struct for each id, which has problems when multiple requests access the struct concurrently.

FVIW: Id don’t define columnkey because the query always returns 1 record and Lucee is omitting the columnkey-level in the resulting struct when only one record is returned.

I assume this is a bug in Lucee?

Important question! Is the resulting struct threadsafe? Or ist the struct shared with all other threads and a manipulation requires locks or duplicate? Would be very counter-intuitive.

Lucee 5.3.8.206

2 Likes

Yep, file a bug please

All structs in Lucee are by default thread safe

Good bug report!

https://luceeserver.atlassian.net/browse/LDEV-3989

2 Likes