<span style="font-size:small;"><span style="font-size:16px;">&nbsp; &nbsp;&nbsp;刚公交车上现场的工程人员打电话说在一个版本为10.2.0.4的AIX RAC上执行一个多表的join查询语句最近老是收到ORA-04030的错误(有时候又没报错),能够确定的是AIX操作系统对资源没有任何限制,内存足够的大,PGA设置是足够的,查询的数据加了WHERE条件,只有过滤出5天的数据。<br /> </span><br /> <span style="font-size:16px;">&nbsp; &nbsp;&nbsp;回到家中吃了饭开始跟同事QQ上一同处理问题。</span><br /> <span style="font-size:16px;">1).首先让同事尝试把PGA调大,不过没有效果一样报错,又改回来了。</span><br /> <span style="font-size:16px;">2).SELECT中包含有GROUP BY语句,让同事去掉之后不报错,或者查询小于等于3天的数据也不报错,怀疑是否是数据量过大造成的PGA分配不够。</span><br /> <span style="font-size:16px;">3).查询V$TEMPSEG_USAGE没有任何记录。</span><br /> <span style="font-size:16px;">4).使用下面的语句查询隐含参数"_pga_max_size"的值。</span><br /> <span style="font-size:16px;">SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ</span><br /> <span style="font-size:16px;">FROM SYS.x$ksppi x, SYS.x$ksppcv y</span><br /> <span style="font-size:16px;">WHERE x.inst_id = USERENV ('Instance')</span><br /> <span style="font-size:16px;">AND y.inst_id = USERENV ('Instance')</span><br /> <span style="font-size:16px;">AND x.indx = y.indx</span><br /> <span style="font-size:16px;">AND x.ksppinm LIKE '%&amp;par%'</span><br /> <br /> <span style="font-size:16px;">输入pga_max_size</span><br /> <span style="font-size:16px;">查询结果是:</span><br /> <span style="font-size:16px;">NAME</span><br /> <span style="font-size:16px;">--------------------------------------------------------------------------------</span><br /> <span style="font-size:16px;">VALUE</span><br /> <span style="font-size:16px;">--------------------------------------------------------------------------------</span><br /> <span style="font-size:16px;">DESCRIB</span><br /> <span style="font-size:16px;">--------------------------------------------------------------------------------</span><br /> <span style="font-size:16px;">_pga_max_size</span><br /> <span style="font-size:16px;">209715200</span><br /> <span style="font-size:16px;">Maximum size of the PGA memory for one process</span><br /> <br /> <span style="font-size:16px;">每个进程能消耗的PGA内存最大值为200M,执行该SQL应该不会操作该值。</span><br /> <span style="font-size:16px;">5).让同事查询了PGA的统计信息:</span><br /> <span style="font-size:16px;">select name,round(value/1024/1024) mb from v$pgastat;</span><br /> <br /> <span style="font-size:16px;">查询结果是:</span><br /> <span style="font-size:16px;">aggregate PGA target parameter 512</span><br /> <span style="font-size:16px;">aggregate PGA auto target 280</span><br /> <span style="font-size:16px;">global memory bound 100</span><br /> <span style="font-size:16px;">total PGA inuse 201</span><br /> <span style="font-size:16px;">total PGA allocated 416</span><br /> <strong><span style="color:#ff0000;"><span style="font-size:16px;">maximum PGA allocated 3227</span><br /> </span></strong><span style="font-size:16px;">total freeable PGA memory 41</span><br /> <span style="font-size:16px;">process count 0</span><br /> <span style="font-size:16px;">max processes count 0</span><br /> <span style="font-size:16px;">PGA memory freed back to OS 209965</span><br /> <span style="font-size:16px;">total PGA used for auto workareas 0</span><br /> <span style="font-size:16px;">maximum PGA used for auto workareas 719</span><br /> <span style="font-size:16px;">total PGA used for manual workareas 0</span><br /> <span style="font-size:16px;">maximum PGA used for manual workareas 192</span><br /> <span style="font-size:16px;">over allocation count 0</span><br /> <span style="font-size:16px;">bytes processed 427185</span><br /> <span style="font-size:16px;">extra bytes read/written 99480</span><br /> <span style="font-size:16px;">cache hit percentage 0</span><br /> <span style="font-size:16px;">recompute count (total) 1</span><br /> <br /> <span style="font-size:16px;">PGA的当前值为512M,最大的时候达到过3227M,不过当前PGA空间应该是足够的。</span><br /> <br /> <span style="font-size:16px;">6).尝试找出SQL查询一天数据花费的PGA空间。</span><br /> <span style="font-size:16px;">&nbsp; &nbsp;&nbsp;让同事登录一个新的会话,先执行报错SQL查询一天的数据,这是不会报错的,然后立即执行以下的SQL找出分配给会话PGA的空间。</span><br /> <span style="font-size:16px;">select v2.name, v1.value</span><br /> <span style="font-size:16px;">&nbsp; from v$mystat v1, v$statname v2</span><br /> <span style="font-size:16px;">&nbsp;where v1.statistic# = v2.statistic# and upper(v2.name) like '%PGA%';</span><br /> <br /> <span style="font-size:16px;">得到的结果是:</span><br /> <span style="font-size:16px;">1 session pga memory 6215360</span><br /> <span style="font-size:16px;">2 session pga memory max 41735872</span><br /> <br /> <span style="font-size:16px;">&nbsp; &nbsp;&nbsp;折算下来查询一天的数据花费的PGA空间在6M左右,这个值乘以5倍也不算大啊,既没有操作单进程最大PGA的限制,也没有超过总的PGA空间的“假”限制。</span><br /> <br /> <span style="font-size:16px;">7).使用putty连接到服务器,使用sqlplus / as sysdba方式登录到数据库实例,执行该SQL不会报ORA-04030的错误。</span><br /> <br /> <span style="font-size:16px;">&nbsp; &nbsp;&nbsp;开始觉得素手无策了,于是又开始在METALINK上看文档,找到一篇详细记录ORA-04030错误的文章,已经分享到我的blog中,</span></span><a href="http://space.itpub.net/23135684/viewspace-712768"><span style="font-size:16px;">http://space.itpub.net/23135684/viewspace-712768</span></a><br /> <br /> <span style="font-size:small;"><span style="font-size:16px;">&nbsp; &nbsp;&nbsp;在文章中看到一些bug,前面已经证实,遇到bug的可能性比较小。看了“Can you control the size of a process?”这小节之后尝试对进程使用的PGA进行手动的控制,于是在执行SQL语句执行执行如下的SQL:</span><br /> <span style="font-size:16px;">ALTER SESSION SET WORKAREA_SIZE_POLICY=MANUAL;</span><br /> <span style="font-size:16px;"><span style="color:#E53333;">然后再次执行SQL居然不报错了!</span><br /> </span><br /> <span style="font-size:16px;">文章上说当设置了PGA_AGGREGATE_TARGET参数之后,所有*_AREA_SIZE参数将被忽略。于是执行ALTER SYSTEM SET WORKAREA_SIZE_POLICY=MANUAL;在系统级别将该参数设置为手动模式(PGA_AGGREGATE_TARGET,WORKAREA_SIZE_POLICY两个参数都是可动态调整的参数),并且将PGA_AGGREGATE_TARGET参数从原有的512M调整为3G。<br /> </span><br /> <span style="font-size:16px;">&nbsp; &nbsp;&nbsp;有关PGA_AGGREGATE_TARGET和WORKAREA_SIZE_POLICY之间的关系可以参见下面的描述:</span><br /> <span style="widows:2;text-indent:0px;border-collapse:separate;font:medium Simsun;white-space:normal;orphans:2;letter-spacing:normal;color:#000000;word-spacing:0px;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;" class="Apple-style-span"><span style="font-family:Tahoma, sans-serif;font-size:small;" class="Apple-style-span"> <p> <span style="font-family:新宋体;font-size:16px;">PGA_AGGREGATE_TARGET</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-size:16px;">specifies the target aggregate PGA memory available to all server processes attached to the instance.</span> </p> <p> <span style="font-size:16px;">Setting</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-family:新宋体;font-size:16px;">PGA_AGGREGATE_TARGET</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-size:16px;">to a nonzero value has the effect of automatically setting the</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-family:新宋体;font-size:16px;">WORKAREA_SIZE_POLICY</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-size:16px;">parameter to</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-family:新宋体;font-size:16px;">AUTO</span><span style="font-size:16px;">. This means that SQL working areas used by memory-intensive SQL operators (such as sort, group-by, hash-join, bitmap merge, and bitmap create) will be automatically sized. A nonzero value for this parameter is the default since, unless you specify otherwise, Oracle sets it to 20% of the SGA or 10 MB, whichever is greater.</span> </p> <p> <span style="font-size:16px;">Setting</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-family:新宋体;font-size:16px;">PGA_AGGREGATE_TARGET</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-size:16px;">to 0 automatically sets the</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-family:新宋体;font-size:16px;">WORKAREA_SIZE_POLICY</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-size:16px;">parameter to</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-family:新宋体;font-size:16px;">MANUAL</span><span style="font-size:16px;">. This means that SQL workareas are sized using the</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-family:新宋体;font-size:16px;">*_AREA_SIZE</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-size:16px;">parameters.</span> </p> <p> <span style="font-size:16px;">Oracle attempts to keep the amount of private memory below the target specified by this parameter by adapting the size of the work areas to private memory. When increasing the value of this parameter, you indirectly increase the memory allotted to work areas. Consequently, more memory-intensive operations are able to run fully in memory and less will work their way over to disk.</span> </p> <p> <span style="font-size:16px;">When setting this parameter, you should examine the total memory on your system that is available to the Oracle instance and subtract the SGA. You can assign the remaining memory to</span><span class="Apple-converted-space" style="font-size:16px;">&nbsp;</span><span style="font-family:新宋体;font-size:16px;">PGA_AGGREGATE_TARGET</span><span style="font-size:16px;">.</span> </p> </span></span><span style="font-size:16px;"><br /> &nbsp; &nbsp;&nbsp;另外,同事反应excel程序使用oracle for oledb驱动程序连接RAC之前也会遇到ORA-04030的错误,oracle for oledb的客户端版本是10.2.0.1,考虑到在该版本的oracle问题比较多,于是将客户端的版本从10.2.0.1升级到10.2.0.5。</span><br /> <br /> <span style="font-size:16px;">&nbsp; &nbsp;&nbsp;<span style="color:#ff0000;"><b>当出现问题素手无策的时候,多看看原理性的文章,可能对我们解决问题会有帮助。<br /> </b><br /> <span style="color:#000000;">&nbsp; &nbsp; 更详细的了解ORA-04030的错误可参考文章:<br /> &nbsp; &nbsp; &nbsp; &nbsp;《</span><span style="color:#000000;">再次遇到ORA-04030的错误</span><span style="color:#000000;"></span><span style="color:#000000;">》:</span><a href="http://blog.itpub.net/23135684/viewspace-1769128/" target="_blank"><span style="color:#000000;">http://blog.itpub.net/23135684/viewspace-1769128/</span></a><span style="color:#000000;"></span><span style="color:#000000;"></span></span></span><br /> <span style="font-size:16px;"><br /> --end--<br /> </span><br /> </span> <div> </div>


©著作权归作者所有:来自51CTO博客作者小麦苗DB宝的原创作品,如需转载,请注明出处,否则将追究法律责任

更多相关文章

  1. 基数反馈(Cardinality Feedback)
  2. 使用DBLINK查询时报ORA-00600: internal error code, arguments:
  3. 11gR2 新特性--待定的统计信息(Pending Statistic)
  4. 【MOS:1549181.1】为何在查询中索引未被使用--为什么索引没有被使
  5. sql 注入
  6. 【知识点整理】NOLOGGING、APPEND、ARCHIVE和PARALLEL下,REDO、UN
  7. 命令执行
  8. Zerodium公开Tor浏览器0day代码执行漏洞 被喷“不负责任”
  9. 简简单单教你设置 ssh 免密登录

随机推荐

  1. Android 系統存在設計漏洞,釣魚網站隨時出
  2. ListView 取消点击效果
  3. 【Android的从零单排开发日记】之入门篇(
  4. android 基础知识整理 1
  5. 详解Android 触摸事件处理和传递过程的来
  6. android 访问SD卡的方法
  7. Android(安卓)API demos 阅读笔记 4
  8. android定义全局变量
  9. Android开发者收入仅相当于iOS应用24%(同
  10. Google 发布 Android @ Home,让你用 Andro