手工生成HTML格式AWR遇到Bug 13527323一例

realkid4發表於2014-02-27

 

Oracle中的AWR報告是目前官方提供的最好的效能分析診斷工具。藉助對於一個連續snapshot的分析,我們可以快速的獲取到整體效能分析指標,綜合定位問題發生點。

 

任何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

 

報告生成失敗,在目錄上雖然有報告檔案、也可以開啟,但是生成檔案不完整。

 

手工生成HTML格式AWR遇到Bug 13527323一例

 

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格式存在問題,那麼更簡單的text格式是否不會丟擲異常呢?

 

 

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'

輸入 report_type 的值:  text

Type Specified:                  text

 

最後結果成功生成:

 

Parameter Name                Begin value                       (if different)

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

control_files                 /home/oracle/controlfile/cogdb/co

                              /oradb/app/oracle/oradata/control

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

Dynamic Remastering Stats               DB/Inst: COGDB/cogdb  Snaps: 9583-9584

                  No data exists for this section of the report.

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

 

End of Report

Report written to awrrpt_1_9583_9584.txt

 

確認報告內容也是完整的。在SQL Text部分,我們也的確發現了“多種語言”的情況。

 

-> Captured PL/SQL account for    0.0% of Total DB Time (s):           3,165

        Elapsed                  Elapsed Time

        Time (s)    Executions  per Exec (s)  %Total   %CPU    %IO    SQL Id

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

           298.0              1        297.99    9.4   50.6   26.6 4wfkj936k5qhq

insert into f_cx_cmain ( select T1."POO" as 單號, T1."CLDE" as

 類程式碼, T1."RDE" as程式碼, T1."CDE" as 公司, T1

."BUODE" as 來原始碼, T1."SE" as 起期, T1."EE" as 終期, T1."UNDDDATE" as通過, T2."STATDATE" a

 

的確和Bug說明的情況相匹配。除了text格式,筆者認為使用OEM產品中的AWR生成模組,也可以避免這類問題的出現。

 

4、結論

 

任何軟體的使用過程中,Bug是難以避免。當操作結果和我們預想不同、而且從經驗判斷不是操作失誤的時候,就可以考慮是Bug的原因。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17203031/viewspace-1095512/,如需轉載,請註明出處,否則將追究法律責任。

相關文章