首页 > 数据库 > Oracle > ora-01000和tablespace不足推断
已经很多次碰见了ora-01000超过最大游标打开数,其实对于此种错误,dba能解决的方案很少,除了增加参数还真想不出什么方法。
Caused by:
java.sql.SQLException: ORA-01000: maximum open cursors exceeded
SQL> show
parameter open_cursors;
NAME TYPE VALUE
------------------------------------
----------- ------------------------------
open_cursors integer 300
查看v$open_session视图来获取session中打开cursor的数量。
SQL> col sid for
99999
SQL> col machine
for a20
SQL> select
o.sid,osuser,machine,count(*) from v$open_cursor o,v$session s
2
where o.user_name='COBRA' and o.sid=s.sid
3
group by o.sid,osuser,machine
4
having count(*)>300;
SID OSUSER MACHINE COUNT(*)
------ ----------
-------------------- ----------
316 root bogon 316
244 root bogon 316
222 root bogon 316
255 root bogon 334
267 root bogon 315
303 root bogon 317
221 root bogon 317
248 root bogon 318
298 root bogon 318
317 root bogon 316
242 root bogon 316
SID OSUSER MACHINE COUNT(*)
------ ----------
-------------------- ----------
234 root
bogon 317
323 root bogon 318
305 root bogon 317
287 root bogon 316
276 root bogon 316
311 root bogon 317
264 root bogon 315
290 root bogon 316
257 root bogon 318
250 root bogon 316
可以看出系统中出现了很多游标打开没有及时释放,这种情况可能是应用程序问题导致的游标没有及时关闭,例如一个循环中频繁打开游标导致,当然也有可能是open_cursors参数的值对于系统确实不够,不过该参数一般是足够的。
而后重启应用又出现了system和用户的表空间不足,加了相应的表空间后,居然没有出现ora-01000错误。
SQL> select
sid,count(*) from v$open_cursor group by sid;
SID
COUNT(*)
----------
----------
321 30
325 14
247 18
294 4
269 24
244 18
311 67
303 69
310 63
245 8
307 1
………
可以发现各session基本的cursor都很小,所以感觉open_cursors并不是根本原因,很有可能是程序问题,不过之后只增加了表空间,对应用程序没有做过修改,个人推断是否因为表空间不足导致cursor没有及时释放,增加表空间后没有出现此类问题了,后续自己再多监控下这个应用。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25362835/viewspace-1059129/ ,如需转载,请注明出处,否则将追究法律责任。