Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Stale Thread Error - Thread has been recycled

SA-76866

Summary



Pega 7.1.7 is built on the Pega Customer Service and Sales Automation (SFA) frameworks.
Database is MSSQL 2012 and WebLogic server 12c.


The data pages are loaded asynchronously on the landing page. When navigating to the Details page on clicking the link, the sections do not render correctly and error occurs.
The sections load correctly when the data pages are loaded synchronously on the landing page.



Error Messages

[fault (self-tuning)'] [STANDARD] [ ] [ ] (internal.mgmt.Executable) ERROR Rule-Connect-SOAP.<<XXXX>>-<<MMM>>-Int-FD-StndrdHeader-CBS-StandardHeader-I-.StandardHeader  - Exception
java.util.ConcurrentModificationException 
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:923)
at java.util.HashMap$ValueIterator.next(HashMap.java:951)
at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
at java.util.ArrayList.<init>(ArrayList.java:166)
at com.pega.pegarules.data.internal.clipboard.PropertySet.iterator(PropertySet.java:137)

and

[fault (self-tuning)'] [STANDARD] [ ] [ ] (mgmt.base.ThreadData) ERROR   - Trying to use a recycled thread
com.pega.pegarules.pub.context.StaleThreadError: Thread has been recycled 
at com.pega.pegarules.session.internal.mgmt.base.ThreadData.validateUse(ThreadData.java:763) 
at com.pega.pegarules.session.internal.mgmt.PRThreadImpl.validateUse(PRThreadImpl.java:156) 
at com.pega.pegarules.session.internal.mgmt.PRThreadImpl.setJavaPageObjectGenerationEnabled(PRThreadImpl.java:983



Steps to Reproduce

Invoke the data page from the UI section through an activity.

Set up a Top Level data page, D_Parent_DataPage.



This invokes multiple child data pages.



Each child data page invokes its respective activity.



In each activity triggered by a child data page, the D_Parent_DataPage is referred.




Root Cause



The D_Parent_DataPage is loaded asynchronously. That is, the data page is loaded in an asynchronous cache area of the memory. The Load-DataPage method loaded the data page asynchronously and with every reference to the data page, it is referred on the asynchronous cache.
The D_Child_DataPage is loaded asynchronously when it is referred in the section.
The data source of the D_Parent_DataPage is an activity which invoked the Load-DataPage for a different embedded D_Child_DataPage. The data source of the embedded data page populated the D_Parent_DataPage and not itself.
Hence, the D_Parent_DataPage is shared in different threads which are created for each embedded data page. This causes Concurrent Modifications exceptions.
Additionally, the owning thread of the D_Parent_DataPage becomes stale and generates the 'Thread has been recycled' message.
At runtime, since each Load-Datapage call refers to the D_Parent_DataPage, they simultaneously update and refer back to the D_Parent_DataPage parent data page.
In an adhoc manner, there are occurrences where the version referred during a specific data page call is outdated (stale) as another thread had updated the same data page which is shared (currently) in the cache area.
This caused issues because multiple threads accessed the same thread which hosted the D_Parent_DataPage.



Resolution



Perform the following local-change:
  1. Load data in to embedded data pages.
  2. When the embedded data page is loaded within its own context, read from the embedded data page and copy to the parent D_Parent_DataPage.
     

Published April 6, 2019 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us