正德厚生,臻于至善

如何跟踪并发请求并生成TKPROF文件

1. 生成跟踪文件

对并发程序启用跟踪功能

选择“启用跟踪”选项

注意: 在并发程序中选择启动跟踪选项提供的是事件10046,级别8的跟踪。所以即使在提交请求的时候选择了绑定变量和等待事件,跟踪依然会被重新设置成级别8,所以在跟踪文件中不会有绑定变量。

启用跟踪

  • 职责:系统管理员
  • 浏览器: 配置文件> 系统
  • 查询配置文件选项:Concurrent: Allow Debugging
  • 选择 “是“

提交启用跟踪的并发请求

  • 登录进含有该并发请求的职责
  • 在提交请求界面点击调试选项(B)
  • 选择 SQL跟踪
如果调试选项是灰色的并且不能被更新,请将配置文件Concurrent: Allow Debugging 设置成“是“

2.找到跟踪文件的文件名

运行下面的一段SQL代码来找到并发请求的原始跟踪文件的文件名以及存放的目录。运行时会弹出选项让用户输入请求的ID。 

prompt  
accept request prompt 'Please enter the concurrent request id for the appropriate concurrent program:'  
prompt  

column traceid format a8  
column tracename format a80  
column user_concurrent_program_name format a40  
column execname format a15  
column enable_trace format a12  
set lines 80  
set pages 22  
set head off 

SELECT 'Request id: '||request_id , 
'Trace id: '||oracle_Process_id, 
'Trace Flag: '||req.enable_trace, 
'Trace Name: 
'||dest.value||'/'||lower(dbnm.value)||'_ora_'||oracle_process_id||'.trc', 
'Prog. Name: '||prog.user_concurrent_program_name, 
'File Name: '||execname.execution_file_name|| execname.subroutine_name , 
'Status : '||decode(phase_code,'R','Running') 
||'-'||decode(status_code,'R','Normal'), 
'SID Serial: '||ses.sid||','|| ses.serial#, 
'Module : '||ses.module 
from fnd_concurrent_requests req, v$session ses, v$process proc, 
v$parameter dest, v$parameter dbnm, fnd_concurrent_programs_vl prog, 
fnd_executables execname 
where req.request_id = &request 
and req.oracle_process_id=proc.spid(+) 
and proc.addr = ses.paddr(+) 
and dest.name='user_dump_dest' 
and dbnm.name='db_name' 
and req.concurrent_program_id = prog.concurrent_program_id 
and req.program_application_id = prog.application_id 
--- and prog.application_id = execname.application_id 
and prog.executable_application_id = execname.application_id
and prog.executable_id=execname.executable_id; 

查看请求运行的时间:

SELECT request_id, TO_CHAR( request_date, 'DD-MON-YYYY HH24:MI:SS' )
request_date, TO_CHAR( requested_start_date,'DD-MON-YYYY HH24:MI:SS' )
requested_start_date, TO_CHAR( actual_start_date, 'DD-MON-YYYY HH24:MI:SS' )
actual_start_date, TO_CHAR( actual_completion_date, 'DD-MON-YYYY HH24:MI:SS' )
actual_completion_date, TO_CHAR( sysdate, 'DD-MON-YYYY HH24:MI:SS' )
current_date, ROUND( ( NVL( actual_completion_date, sysdate ) - actual_start_date ) * 24, 2 ) duration
FROM fnd_concurrent_requests
WHERE request_id = TO_NUMBER('&p_request_id');

你也可以根据文档Note:187504.1 bde_request.sql Process and Session info for one Concurrent Request(11.5)和请求的ID来生成完整的报告 

3. TKPROF 跟踪文件

当你得到了原始跟踪文件的时候,你需要通过TKPROF来转换它的格式。

$ tkprof raw_trace_file.trc output_file explain=apps/apps sort=(exeela,fchela) sys=no
$ tkprof PROD1_ora_122629_DEHETU.trc PROD1_ora_122629_DEHETU.txt explain=apps/apps sys=no sort=exeela,prsela,fchela

Where:

raw_trace_file.trc: Name of trace file
output_file:        tkprof out file
explain:            This option provides the explain plan for the sql 
                    statements
sort:               This provides the sort criteria in which all sql
                    statements will be sorted.  This will bring the bad sql at
                    the top of the outputfile.
sys=no:             Disables sql statements issued by user SYS
另一个例子:下列命令会生成一个按照运行时间的长短进行排序,并且结果只含有运行时间最长的10个查询语句的跟踪文件。

 

$ tkprof <filename.trc> <output_filename> sys=no explain=apps/<password> sort='(prsela,exeela,fchela)' print=10
  注意:在11g之前的数据库版本中,使用下列语句查询原始跟踪文件保存的目录:

select value from v$parameter where name = 'user_dump_dest';
在11g数据库中,使用下列语句:

select value from v$diag_info where name = 'Diag Trace';

4. 基于fnd_log_messages之上的调试

如果你需要做更多的调试从而得到更详细的错误信息,请让客户执行下列的步骤

 1) 登录进系统管理员职责并设定下列系统配置文件选项:

 FND: Debug Log Enabled - Yes
 FND: Debug Log Level - Statement
 FND: Debug Log Module - %
 FND: Message Level Threshold to low level
 [ 以上配置请设置在用户层上 ]    2) 运行下列查询语句: 

 SELECT MAX(log_sequence) FROM fnd_log_messages;
   得到最大的日志序列号,也就是在第五步中使用的log_seq1    3) 通过第一步中设置配置文件的用户来重现问题。
 4) 运行下列查询语句:  

 SELECT MAX(log_sequence) FROM fnd_log_messages;
   得到最大的日志序列号,也就是在第五步中使用的log_seq2。    5) 运行下列语句得到日志信息:

 SELECT LOG_SEQUENCE, MESSAGE_TEXT, USER_ID FROM fnd_log_messages WHERE
 log_sequence > log_seq1-1 and log_sequence < log_seq2+1 ;

NOTE:967966.1 – How to find the Trace file generated for a concurrent program?
NOTE:791049.1 – R12 SLA/FAH: How to Improve Performance in Subledger Accounting & Financials Accounting Hub
NOTE:421245.1 – E-Business Suite Diagnostics References for R12
NOTE:187504.1 – Concurrent Processing – bde_request.sql – Process and Session info for one Concurrent Request (11.5)
NOTE:1536264.1 – 如何跟踪并发请求并生成TKPROF文件
NOTE:1674024.1 – Oracle E-Business SQL Trace and TKPROF Guide

赞(1) 打赏
未经允许不得转载:徐万新之路 » 如何跟踪并发请求并生成TKPROF文件

评论 抢沙发

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫

微信扫一扫

登录

找回密码

注册