mysql - How to show a list of all open database cursors? -


context

we have (java, jpa:eclipselink) application connected mysql.

there cases want fetch thousands of results, , perform action per-result. not want hold whole result set in-memory.

jpa:eclipselink's queries "scrollable cursor" allow iterate lazily through result set, keeping 1 result in-memory @ time.

it understanding these queries "scrollable cursor" implemented in mysql cursor.

problem

it consumer's responsibility "close" mysql cursor.

we have trouble guaranteeing cursor gets closed. naturally close cursor when reach end of result set, there problems prevent iterating far that:

  • exception thrown
  • program exit
  • intentional early-exit of iteration
    • e.g. question "is non-zero amount of results returned?"

anecdotes

we have observed before that: leaving many cursors open, uses available connections in our database connection pool. once limit reached: subsequent queries fail because no further database connections available.

we have suspicion completing transaction close open database cursors participating in transaction. if so: provide useful safeguard. have yet measure whether indeed happen, , haven't yet worked out level of transaction provides guard (mysql transaction? jpa transaction? spring transaction?). answer question below, enable measure this…

question

is possible in mysql show list of currently-open database cursors? if so: how?


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -