手工生成HTML格式AWR遇到Bug 13527323解决实例(一)

2014-11-24 17:24:21 · 作者: · 浏览: 2

任何Oracle版本中,我们都可能会遇到各种类型的Bug。发现Bug之后,和官方公布内容进行匹配确认,找到解决或者规避方法,是数据库使用者应该具备的一种能力。


1、环境介绍和故障发生


笔者在11.2.0.3环境下,生成巡检AWR报告,想查看业务高峰期作业负载情况。


SQL> select * from v$version;



BANNER


------------------------------------


Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production


PL/SQL Release 11.2.0.3.0 - Production


CORE 11.2.0.3.0 Production


TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production


NLSRTL Version 11.2.0.3.0 – Production


使用sqlplus命令行来进行报告生成过程,调用awrrpt.sql。


D:\>sqlplus /nolog


SQL*Plus: Release 11.2.0.1.0Production on 星期四 2月 27 09:07:02 2014


Copyright (c) 1982, 2010, Oracle. All rights reserved.


SQL> @ /rdbms/admin/awrrpt.sql


Current Instance


~~~~~~~~~~~~~~~~



DB Id DB Name Inst Num Instance


----------- ------------ -------- ------------


1083126127 COGDB 1 cogdb



Specify the Report Type


~~~~~~~~~~~~~~~~~~~~~~~


Would you like an HTML report, or a plain text report


Enter 'html' for an HTML report, or 'text' for plain text


AWR目前支持两个格式,html和text格式。text格式是从AWR的前身statspack中延续而来,格式简单、生成负载小,但是可读性不强。html格式是我们通常的选择。


但是,本次报告出错。



8


 



SELECT dbin.instance_number, d...



ERROR:


ORA-06502: PL/SQL: 数字或值错误 : 字符串缓冲区太小


ORA-06512: 在 "SYS.DBMS_WORKLOAD_REPOSITORY", line 919


ORA-06512: 在 line 1



Report written to awrrpt_1_9583_9584.html


报告生成失败,在目录上虽然有报告文件、也可以打开,但是生成文件不完整。


2、问题检查和确定


一般而言,客户端脚本和服务器端程序不匹配,通常是造成脚本执行的一个很重要的原因。比如:我们使用10g客户端的旧脚本,调用11g服务器的新程序,是可能引起故障的。比较典型的就是还原数据字典的过程。


AWR生成脚本awrrpt.sql虽然是在客户端,但是只是负责参数数据收集和传入。生成AWR报告的关键程序是dbms_workload_repository包,awrrpt.sql并不直接和AWR数据字典打交道。所以,由于版本差异引起的问题,在这个案例上可能性是很低的。


为了预防万一,我们在服务器端进行报告生成。


[oracle@MISDB:~]$cd /tmp


[oracle@MISDB:/tmp]$sqlplus /nolog



SQL*Plus: Release 11.2.0.3.0 Production on Thu Feb 27 09:13:23 2014


Copyright (c) 1982, 2011, Oracle. All rights reserved.



SQL> conn / as sysdba


Connected.



SQL> @ /rdbms/admin/awrrpt.sql


Current Instance


~~~~~~~~~~~~~~~~


DB Id DB Name Inst Num Instance


----------- ------------ -------- ------------


1083126127 COGDB 1 cogdb



Specify the Report Type


~~~~~~~~~~~~~~~~~~~~~~~


Would you like an HTML report, or a plain text report


Enter 'html' for an HTML report, or 'text' for plain text


Defaults to 'html'


Enter value for report_type:


要求生成html格式报告,依然报错。


 



SELECT dbin.instance_number, d...



ERROR:


ORA-06502: PL/SQL: numeric or value error: character string buffer too small


ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 919


ORA-06512: at line 1


Report written to awrrpt_1_9583_9584.html


这种场景的确是不正常的,而且由于代码加密的原因,我们也不能真的跟踪到line 919行。这个时候可能就需要求助于官方经验集合MOS。


经过查询,在MOS中有一篇对于Bug13527323的介绍,文章编号为: ORA-6502 generating HTML AWR report using awrrpt.sql in Multibyte characterset database (文档 ID 13527323.8)。

文章中,Oracle说在一些时候,使用awrrpt.sql脚本生成报告是会抛出错误ora-6502的。对应的影响版本为11.2.0.3,而且Oracle认为在12.1一下都可能发生错误。这个描述与当前笔者遇到的情况相同。


对于故障原因,Oracle解释是:In case of multibyte characters in SQL text, sometime AWR report generation fails with error ORA-6502. Also sending more than 4000 bytes of single varchar data to JDBC api's causes truncation of data.

Rediscovery Notes:


If html AWR report generation fails with ORA-6502 or generating


AWR report using JDBC api's causes truncation of data then this bug


as probably been rediscovered.


如果在SQL text中存在多种语言表示,那么在数据输出的时候,就会抛出异常ora-6502。


问题基本上就可以确定是这个了。那么怎么解决呢?对于策略,Oracle没有明确说补丁集合之类,只说这种情况比较偶然。


3、问题解决


虽然定位了问题,但是终究还是需要解决的。html格