简体   繁体   中英

Jasper reports causing CURSOR issues with SELECT statements

We are using Jasper reports with java for one of our reporting application and use 'SELECT' queries to fetch data and generate reports using Jasper reporting templates. They are a bunch of old queries, some are not tuned, their performance depends on the parameters they take. Ex-date ranges, categories, etc.

Lately, we have been experiencing weird cursor issues, the count of cursors the app is holding is going high, up to 900 at times, this is causing some serious space issues. We are manually closing them to temporarily overcome this issue. However, the issue is coming back again and again and has been a serious concern.

My understanding of the 'SELECT' statements is that they will implicitly use the CURSOR methodology, but make sure that once the operations are complete, they are closed. And we don't have much control from the application side.

Debugging / Troubleshooting the issue:

  • Database used - Oracle, Jasper - jasperreports-3.7.0, ODBC driver - ojdbc14
  • We ran the query though DBA and see no issues, again it's just a regular SELECT query and we are not explicitly creating any cursor.

  • Changed the DB calls to a read-only state, didn't work.

  • Looks like Jasper server uses regular JDBC prepared statements - ODBC driver - ojdbc14.

  • No pagination used.

Question :

We are out of leads on this issue, if someone can help us with this it would be great.

Edit

SID =4385 has the following sql with count of open cursor

SQL_ID COUNT(*)


  • djuwsn5numsqv 2
  • fw5920rbrun82 131 0wk7fbztn67zh 1
  • c29qmb59gggtv 1
  • 6y1ajq8xaw294 1
  • 9q3btvwzg96k6 487 ------->>>
  • 3zzkryq60kua1 1
  • anp287ycdrnp6 1
  • 58tzy7dhpwnq4 1
  • cfgz3kzhx53jy 1
  • 0bxwy62tx9n2w 1
  • cygg3t2hc6mr2 12
  • 29s08m4n6xuwt 1

sql_id = 9q3btvwzg96k6 keeps opening the new cursors.

The local static cursors are closed for you.

you can see the max open cursors parameter as below:

show parameter open_cursor

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
open_cursors                         integer     300

Cursors opened within the inner block have obviously not been implicitly closed. Had they been closed, I would not have exceeded the maximum number of open cursors.

If cursor is already opened then Do Not close it , just use it.

In any case the quickest fix would be to

alter system set open_cursors = 1000 scope=both;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM