1-- NAME: DRMDIAG.SQL
2-- ------------------------------------------------------------------------
3-- AUTHOR: Oracle Support Services
4-- ------------------------------------------------------------------------
5-- PURPOSE:
6-- This script is intended to provide a user friendly guide to troubleshoot
7-- drm (dynamic resource remastering) waits. The script will create a file
8-- called drmdiag_<timestamp>.out in your local directory.
9set echo off
10set feedback off
11column timecol new_value timestamp
12column spool_extension new_value suffix
13select to_char(sysdate,'Mondd_hh24mi') timecol,
14'.out' spool_extension from sys.dual;
15column output new_value dbname
16select value || '_' output
17from v$parameter where name = 'db_name';
18spool drmdiag_&&dbname&×tamp&&suffix
19set trim on
20set trims on
21set lines 140
22set pages 100
23set verify off
24set feedback on
25
26PROMPT DRMDIAG DATA FOR &&dbname&×tamp
27PROMPT Important paramenters:
28PROMPT
29PROMPT _gc_policy_minimum (default is 1500). Increasing this would cause DRMs to happen less frequently.
30PROMPT Use the "OBJECT_POLICY_STATISTICS" section later in this report to see how active various objects are.
31PROMPT
32PROMPT _gc_policy_time (default to 10 (minutes)). Amount of time to evaluate policy stats. Use the
33PROMPT "OBJECT_POLICY_STATISTICS" section later in this report to see how active various objects are for the
34PROMPT _gc_policy_time. Usually not necessary to change this parameter.
35PROMPT
36PROMPT _gc_read_mostly_locking (default is TRUE). Setting this to FALSE would disable read mostly related DRMs.
37PROMPT
38PROMPT gcs_server_processes (default is derived from CPU count/4). May need to increase this above the
39PROMPT default to add LMS processes to complte the work during a DRM but the default is usually adequate.
40PROMPT
41PROMPT _gc_element_percent (default is 110). May need to apply the fix for bug 14791477 and increase this to
42PROMPT 140 if running out of lock elements. Usually not necessary to change this parameter.
43PROMPT
44PROMPT GC Related parameters set in this instance:
45show parameter gc
46PROMPT
47PROMPT CPU count on this instance:
48show parameter cpu_count
49
50PROMPT
51PROMPT SGA INFO FOR &&dbname&×tamp
52PROMPT
53PROMPT Larger buffer caches (above 100 gig) may increase the cost of DRMs significantly.
54set lines 120
55set pages 100
56column component format a40 tru
57column current_size format 99999999999999999
58column min_size format 99999999999999999
59column max_size format 99999999999999999
60column user_specified_size format 99999999999999999
61select component, current_size, min_size, max_size, user_specified_size
62from v$sga_dynamic_components
63where current_size > 0;
64
65PROMPT
66PROMPT ASH THRESHOLD...
67PROMPT
68PROMPT This will be the threshold in milliseconds for total drm freeze
69PROMPT times. This will be used for the next queries to look for the worst
70PROMPT 'drm freeze' minutes. Any minutes that have an average log file
71PROMPT sync time greater than the threshold will be analyzed further.
72column threshold_in_ms new_value threshold format 999999999.999
73select decode(min(threshold_in_ms),null,0,min(threshold_in_ms)) threshold_in_ms
74from (select inst_id, to_char(sample_time,'Mondd_hh24mi') minute,
75sum(time_waited)/1000 threshold_in_ms
76from gv$active_session_history
77where event like '%drm freeze%'
78group by inst_id,to_char(sample_time,'Mondd_hh24mi')
79order by 3 desc)
80where rownum <= 10;
81
82PROMPT
83PROMPT ASH WORST MINUTES FOR DRM FREEZE WAITS:
84PROMPT
85PROMPT APPROACH: These are the minutes where the avg drm freeze time
86PROMPT was the highest (in milliseconds).
87column event format a30 tru
88column program format a35 tru
89column total_wait_time format 999999999999.999
90column avg_time_waited format 999999999999.999
91select to_char(sample_time,'Mondd_hh24mi') minute, inst_id, event,
92sum(time_waited)/1000 TOTAL_WAIT_TIME , count(*) WAITS,
93avg(time_waited)/1000 AVG_TIME_WAITED
94from gv$active_session_history
95where event like '%drm freeze%'
96group by to_char(sample_time,'Mondd_hh24mi'), inst_id, event
97having sum(time_waited)/1000 > &&threshold
98order by 1,2;
99
100PROMPT
101PROMPT ASH DRM BACKGROUND PROCESS WAITS DURING WORST MINUTES:
102PROMPT
103PROMPT APPROACH: What are LMS and RS/RMV doing when 'drm freeze' waits
104PROMPT are happening? LMD and LMON info may also be relevant
105column inst format 999
106column minute format a12 tru
107column event format a50 tru
108column program format a55 wra
109select to_char(sample_time,'Mondd_hh24mi') minute, inst_id inst,
110sum(time_waited)/1000 TOTAL_WAIT_TIME , count(*) WAITS,
111avg(time_waited)/1000 AVG_TIME_WAITED,
112program, event
113from gv$active_session_history
114where to_char(sample_time,'Mondd_hh24mi') in (select to_char(sample_time,'Mondd_hh24mi')
115from gv$active_session_history
116where event like '%drm freeze%'
117group by to_char(sample_time,'Mondd_hh24mi'), inst_id
118having sum(time_waited)/1000 > &&threshold and sum(time_waited)/1000 > 0.5)
119and (program like '%LMS%' or program like '%RS0%' or program like '%RMV%'
120or program like '%LMD%' or program like '%LMON%' or event like '%drm freeze%')
121group by to_char(sample_time,'Mondd_hh24mi'), inst_id, program, event
122order by 1,2,3,5 desc, 4;
123
124PROMPT
125PROMPT POLICY HISTORY INFO:
126PROMPT See if you can correlate policy history events with minutes of high
127PROMPT wait time.
128select * from gv$policy_history
129order by event_date;
130PROMPT
131PROMPT DYNAMIC_REMASTER_STATS
132PROMPT This shows where time is spent during DRM operations.
133set heading off
134set lines 60
135select 'Instance: '||inst_id inst, 'Remaster Ops: '||remaster_ops rops,
136'Remaster Time: '||remaster_time rtime, 'Remastered Objects: '||remastered_objects robjs,
137'Quiesce Time: '||quiesce_time qtime, 'Freeze Time: '||freeze_time ftime,
138'Cleanup Time: '||cleanup_time ctime, 'Replay Time: '||replay_time rptime,
139'Fixwrite Time: '||fixwrite_time fwtime, 'Sync Time: '||sync_time stime,
140'Resources Cleaned: '||resources_cleaned rclean,
141'Replayed Locks Sent: '||replayed_locks_sent rlockss,
142'Replayed Locks Received: '||replayed_locks_received rlocksr,
143'Current Objects: '||current_objects
144from gv$dynamic_remaster_stats
145order by 1;
146set lines 120
147set heading on
148
149PROMPT
150PROMPT OBJECT_POLICY_STATISTICS:
151PROMPT The sum of the last 3 columns (sopens,xopens,xfers) decides whether the object
152PROMPT will be considered for DRM (_gc_policy_minimum). The duration of the stats
153PROMPT are controlled by _gc_policy_time (default is 10 minutes).
154select object,node,sopens,xopens,xfers from x$object_policy_statistics;
155
156PROMPT
157PROMPT ACTIVE OBJECTS (OBJECT_POLICY_STATISTICS)
158PROMPT These are the objects that are above the default _gc_policy_minimum (1500).
159select object, node, sopens+xopens+xfers activity
160from x$object_policy_statistics
161where sopens+xopens+xfers > 1500
162order by 3 desc;
163
164PROMPT LWM FOR LE FREELIST
165PROMPT This number should never get near zero, if it does consider the fix for bug 14791477
166PROMPT and/or increasing _gc_element_percent.
167select sum(lwm) from x$kclfx;
168
169PROMPT
170PROMPT GCSPFMASTER INFO WITH OBJECT NAMES
171column objname format a120 tru
172select o.name || ' - '|| o.subname objname, o.type#, h.*
173from v$gcspfmaster_info h, obj$ o where h.data_object_id=o.dataobj#
174order by data_object_id;
175
176PROMPT
177PROMPT ASH DETAILS FOR WORST MINUTES:
178PROMPT
179PROMPT APPROACH: If you cannot determine the problem from the data
180PROMPT above, you may need to look at the details of what each session
181PROMPT is doing during each 'bad' snap. Most likely you will want to
182PROMPT note the times of the high drm freeze waits, look at what
183PROMPT LMS, RS, RMV, LMD0, LMON is doing at those times, and go from there...
184set lines 140
185column program format a45 wra
186column sample_time format a25 tru
187column event format a30 tru
188column time_waited format 999999.999
189column p1 format a40 tru
190column p2 format a40 tru
191column p3 format a40 tru
192select sample_time, inst_id inst, session_id, program, event, time_waited/1000 TIME_WAITED,
193p1text||': '||p1 p1,p2text||': '||p2 p2,p3text||': '||p3 p3
194from gv$active_session_history
195where to_char(sample_time,'Mondd_hh24mi') in (select
196to_char(sample_time,'Mondd_hh24mi')
197from gv$active_session_history
198where event like '%drm freeze%'
199group by to_char(sample_time,'Mondd_hh24mi'), inst_id
200having sum(time_waited)/1000 > &&threshold)
201and time_waited > 0.5
202order by 1,2,3,4,5;
203
204spool off
205
206PROMPT
207PROMPT OUTPUT FILE IS: drmdiag_&&dbname&×tamp&&suffix
208PROMPT