Wednesday, October 30, 2013

WebLogic Stuck Thread Case - Large Fetch Generated by Get Row ADF BC Method

This post is not about a bug, but rather about hidden underwater stone to avoid. Based on my previous use case for WebLogic Stuck Thread - Reproducing WebLogic Stuck Threads with ADF CreateInsert Operation and ORDER BY Clause, I will describe one more possible scenario for the same issue. This will be related to ADF BC API misuse, often it is unclear what side effect could produce at first friendly looking method. This method - getRow(key).

Please download complete sample application, if you are interested to reproduce it in your environment - LargeFetchApp_v3.zip.

This sample provides a method to generate dummy data for regions, around 10000 rows. View Object is using ORDER BY to display records in ascending order:


There is custom method created in AM implementation class. This method is calling ADF BC API getRow(key) method. Nothing dangerous at first, but here I'm using a key of the last record from the rowset - 10099. You may think, this is just a method to get a row by key.  Yes true, but what it does for you - before returning one row by key, it will fetch all rows until this row into memory. It travels through each row one by one, until it gets a row with defined key. This may consume a lot of memory, especially if rowset is large and row with defined key is somewhere at the end of the rowset. Example of such method:


Make sure ADF Logger config is enabled for RegionsViewImpl class:


Press Get Row button to invoke our custom method from above:


You will see - all rows are fetched and loaded into memory, before desired row is located:


If there will be concurrent users executing the same operation, sooner or later there will be Stuck Thread created in WebLogic and application will hang.

By the way, same applies for Last button use case in ADF, you should never use Last button - operation Last is going to fetch all rows in between, until it will get to the last row in the rowset.

5 comments:

Prabhanjan said...

Nice One!!!!

S├ębastien said...

Hi Andrejus,

What's the best solution to get one row by key? Create a view criteria based on the id or use the method findByKey(myKey, 1)?

Regards

Andrejus Baranovskis said...

I will post update for this soon and let you know.

Andrejus

Andrejus Baranovskis said...

Sebastien, I have posted update to your question here: http://andrejusb.blogspot.com/2013/11/find-by-key-and-view-criteria-row.html

Andrejus

Anonymous said...

Thank you!

S├ębastien