Search Oracle Related Sites

Friday, July 15, 2011

Top 5 Timed Events - log file switch (archiving needed)

log file switch (archiving needed) -- Waiting for a log switch because the log that the LGWR will be switching into has not been archived yet. The main cause of this error is due to the non availability of space in the archive log destination.


Database is literally hung in this situation, even thought DB is not physically down, all the operations will come to a standstill affecting the uptime and availability of the system.
The best approach if one runs out of space in the archive log destination is to configure alternative location for archive log destination to avoid outages due to space issues.
Oracle has got an option to add Alternate attribute added to the log_archive_destination. Alternate archiving destination will be used if archiving to the original archiving destination fails. Below link will provide more information about the alternate option.



Thursday, July 7, 2011

11g Top 5 Timed Foregorund Events

From 11g, Oracle replaced “Top 5 Timed Events” as “Top 5 Timed Foreground Events”

Prior to Oracle 11g, wait event statistics included both foreground processes (for example, session based) and background processes (such as DBWR, SMON). It makes sense to break those different process types down into different sets of wait event statistics. He is now making clear in AWR with Foreground and Background events which will help us to focus more on foreground events.

Find below images of new names in 11g.



We will discuss more enhancements like Wait Event Histogram in next post.

Friday, June 24, 2011

AWR TOP 5 Timed Events Analysis - gc buffer busy

I already mentioned about this event in the same blog few months back. But this example is more lively in terms of finding the root cause with the help of AWR.

The gc current block busy and gc cr block busy wait events indicate that the local instance that is making the request did not immediately receive a current or consistent read block. The term "busy" in these events' names indicates that the sending of the block was delayed on a remote instance. For example, a block cannot be shipped immediately if Oracle Database has not yet written the redo for the block's changes to a log file.



In comparison to "block busy" wait events, a gc buffer busy event indicates that Oracle Database cannot immediately grant access to data that is stored in the local buffer cache. This is because a global operation on the buffer is pending and the operation has not yet completed. In other words, the buffer is busy and all other processes that are attempting to access the local buffer must wait to complete.
This AWR belongs to 3 Node RAC Architecture, we see high gc buffer busy in one of the busy nodes. You need to drill down further down in the AWR to the SQL Ordered by Cluster Wait Time section ( Fig 2)and see what query is on the top waiting for the resources. One you pick the query look for the object which is being referred in the query.



In this case we have seen a table (referred in the top sql of Cluster Wait) which is being frequently accessed by all the 3 nodes is constantly being updated by another process.

Further drill down in the AWR to 'Segments by Global Cache Buffer Busy ' to find out the object on which most of the buffer waits are being found. If the table identified in the query matches with that of the Global Cache Buffer Busy section then identify all the DML operations on that table to figure out the solution.


In our case the application is using the same table for updates and selects which is causing the issue. The other quick fix is to see that update application and select application are being routed to the same node to avoid the gc wait event. But it is always better to identify the hot block and try to fix it from the design level for the optimal solution.

Wednesday, June 8, 2011

AWR Top 5 Timed Events - Quick Reference Guide

Wait Events Quick Reference Guide

    Wait Events                                                    Wait Problem Potential Fix

DB File Scattered Read       ----  Indicates many full table scans: tune the code; cache small tables.

DB File Sequential Read      ----  Indicates many index reads: tune the code (especially joins).

Free Buffer                           --- Increase the DB_CACHE_SIZE; shorten the checkpoint; tune the code.

Buffer Busy                          ---Segment header: add freelists or freelist groups.

Buffer Busy                          ---Data block: separate "hot" data; use reverse key indexes and/or smaller
                                                  blocks.

Buffer Busy                          ---Data block: increase initrans and/or maxtrans.

Buffer Busy                          ---Undo header: add rollback segments or areas.

Buffer Busy                          ---Undo block: commit more often; use larger rollback segments or areas.

Latch Free                            ---Investigate the latch detail.

Enqueue                               ---ST Use LMTs or preallocate large extents.

Enqueue                               ---HW Preallocate extents above high-water mark.

Enqueue                               ---TX4 Increase initrans and/or maxtrans on the table or index.

Enqueue                               ---TM Index foreign keys; check application locking of tables.

Log Buffer                            ---Space Increase the log buffer; use faster disks for the redo logs.

Log File                                ---Switch Archive destination slow or full; add more or larger redo logs.

Log File Sync                        --- Commit more records at a time; use faster redo log disks .

Idle Event                              ---Ignore it.

*** Potential Fixes discussed above are subject to change based on the version/feature.

Monday, June 6, 2011

AWR Top 5 Timed Events - Top 10

Top 5 Timed Events


When you are trying to eliminate bottlenecks on your system, your AWR report’s Top 5 Timed Events section is the first place to look. This section of the report shows the top 5 timed events, the full list of wait events, and the background wait events.


The following are 10 of the most common causes for wait events, along with explanations and potential solutions:

1. DB File Scattered Read. This generally indicates waits related to full table scans. As full table scans are pulled into memory, they rarely fall into contiguous buffers but instead are scattered throughout the buffer cache. A large number here indicates that your table may have missing or suppressed indexes. Although it may be more efficient in your situation to perform a full table scan than an index scan, check to ensure that full table scans are necessary when you see these waits. Try to cache small tables to avoid reading them in over and over again, since a full table scan is put at the cold end of the LRU (Least Recently Used) list.

2. DB File Sequential Read. This event generally indicates a single block read (an index read, for example). A large number of waits here could indicate poor joining orders of tables, or unselective indexing. It is normal for this number to be large for a high-transaction, well-tuned system, but it can indicate problems in some circumstances. You should correlate this wait statistic with other known issues within the Statspack report, such as inefficient SQL. Check to ensure that index scans are necessary, and check join orders for multiple table joins. The DB_CACHE_SIZE will also be a determining factor in how often these waits show up. Problematic hash-area joins should show up in the PGA memory, but they're also memory hogs that could cause high wait numbers for sequential reads. They can also show up as direct path read/write waits. These circumstances are usually interrelated. When they occur in conjunction with the appearance of the db file scattered read and db file sequential read in the Top 5 Wait Events section, first you should examine the SQL Ordered by Physical Reads section of the report, to see if it might be helpful to tune the statements with the highest resource usage. Then, to determine whether there is a potential I/O bottleneck, examine the OS I/O statistics for corresponding symptoms. Also look at the average time per read in the Tablespace and File I/O sections of the report. If many I/O-related events appear high in the Wait Events list, re-examine the host hardware for disk bottlenecks and check the host-hardware statistics for indications that a disk reconfiguration may be of benefit.

3. Free Buffer. This indicates your system is waiting for a buffer in memory, because none is currently available. Waits in this category may indicate that you need to increase the DB_BUFFER_CACHE, if all your SQL is tuned. Free buffer waits could also indicate that unselective SQL is causing data to flood the buffer cache with index blocks, leaving none for this particular statement that is waiting for the system to process. This normally indicates that there is a substantial amount of DML (insert/update/delete) being done and that the Database Writer (DBWR) is not writing quickly enough; the buffer cache could be full of multiple versions of the same buffer, causing great inefficiency. To address this, you may want to consider accelerating incremental checkpointing, using more DBWR processes, or increasing the number of physical disks. To investigate if this is an I/O problem, look at the statspack file I/O Statistics.

4. Buffer Busy. This is a wait for a buffer that is being used in an unshareable way or is being read into the buffer cache. Buffer busy waits should not be greater than 1 percent. Check the Buffer Wait Statistics section (or V$WAITSTAT) to find out if the wait is on a segment header. If this is the case, increase the freelist groups or increase the pctused to pctfree gap. If the wait is on an undo header, you can address this by adding rollback segments; if it's on an undo block, you need to reduce the data density on the table driving this consistent read or increase the DB_CACHE_SIZE. If the wait is on a data block, you can move data to another block to avoid this hot block, increase the freelists on the table, or use Locally Managed Tablespaces (LMTs). If it's on an index block, you should rebuild the index, partition the index, or use a reverse key index. To prevent buffer busy waits related to data blocks, you can also use a smaller block size: fewer records fall within a single block in this case, so it's not as "hot." When a DML (insert/update/ delete) occurs, Oracle Database writes information into the block, including all users who are "interested" in the state of the block (Interested Transaction List, ITL). To decrease waits in this area, you can increase the initrans, which will create the space in the block to allow multiple ITL slots. You can also increase the pctfree on the table where this block exists (this writes the ITL information up to the number specified by maxtrans, when there are not enough slots built with the initrans that is specified).

5. Latch Free. Latches are low-level queuing mechanisms (they're accurately referred to as mutual exclusion mechanisms) used to protect shared memory structures in the system global area (SGA). Latches are like locks on memory that are very quickly obtained and released. Latches are used to prevent concurrent access to a shared memory structure. If the latch is not available, a latch free miss is recorded. Most latch problems are related to the failure to use bind variables (library cache latch), redo generation issues (redo allocation latch), buffer cache contention issues (cache buffers LRU chain), and hot blocks in the buffer cache (cache buffers chain). There are also latch waits related to bugs; check MetaLink for bug reports if you suspect this is the case (oracle.com/support ). When latch miss ratios are greater than 0.5 percent, you should investigate the issue. I will cover latch waits in detail in my next Oracle Magazine column; the topic requires an article in itself. If latch free waits are in the Top 5 Wait Events or high in the complete Wait Events list, look at the latch-specific sections of the Statspack report to see which latches are contended for.

6. Enqueue. An enqueue is a lock that protects a shared resource. Locks protect shared resources, such as data in a record, to prevent two people from updating the same data at the same time. An enqueue includes a queuing mechanism, which is FIFO (first in, first out). Note that Oracle's latching mechanism is not FIFO. Enqueue waits usually point to the ST enqueue, the HW enqueue, the TX4 enqueue, and the TM enqueue. The ST enqueue is used for space management and allocation for dictionary-managed tablespaces. Use LMTs, or try to preallocate extents or at least make the next extent larger for problematic dictionary-managed tablespaces. HW enqueues are used with the high-water mark of a segment; manually allocating the extents can circumvent this wait. TX4s are the most common enqueue waits. TX4 enqueue waits are usually the result of one of three issues. The first issue is duplicates in a unique index; you need to commit/rollback to free the enqueue. The second is multiple updates to the same bitmap index fragment. Since a single bitmap fragment may contain multiple rowids, you need to issue a commit or rollback to free the enqueue when multiple users are trying to update the same fragment. The third and most likely issue is when multiple users are updating the same block. If there are no free ITL slots, a block-level lock could occur. You can easily avoid this scenario by increasing the initrans and/or maxtrans to allow multiple ITL slots and/or by increasing the pctfree on the table. Finally, TM enqueues occur during DML to prevent DDL to the affected object. If you have foreign keys, be sure to index them to avoid this general locking issue.

7. Log Buffer Space. This wait occurs because you are writing the log buffer faster than LGWR can write it to the redo logs, or because log switches are too slow. To address this problem, increase the size of the log files, or increase the size of the log buffer, or get faster disks to write to. You might even consider using solid-state disks, for their high speed.

8. Log File Switch. All commit requests are waiting for "logfile switch (archiving needed)" or "logfile switch (chkpt. Incomplete)." Ensure that the archive disk is not full or slow. DBWR may be too slow because of I/O. You may need to add more or larger redo logs, and you may potentially need to add database writers if the DBWR is the problem.

9. Log File Sync. When a user commits or rolls back data, the LGWR flushes the session's redo from the log buffer to the redo logs. The log file sync process must wait for this to successfully complete. To reduce wait events here, try to commit more records (try to commit a batch of 50 instead of one at a time, for example). Put redo logs on a faster disk, or alternate redo logs on different physical disks, to reduce the archiving effect on LGWR. Don't use RAID 5, since it is very slow for applications that write a lot; potentially consider using file system direct I/O or raw devices, which are very fast at writing information.

10. Idle Event. There are several idle wait events listed after the output; you can ignore them. Idle events are generally listed at the bottom of each section and include such things as SQL*Net message to/from client and other background-related timings. Idle events are listed in the stats$idle_event table.





Tuesday, May 31, 2011

AWR Top 5 Timed Events - TCP Socket (KGAS)


TCP Socket (KGAS)


A session is waiting for an external host to provide requested data over a network socket. The time that this wait event tracks does not indicate a problem, and even a long wait time is not a reason to contact Oracle Support. It naturally takes time for data to flow between hosts over a network, and for the remote aspect of an application to process any request made to it. An application that communicates with a remote host must wait until the data it will read has arrived.


"The db session cannot proceed to do anything else until the external host provides the requested data over the network socket. "

KGAS = > is a component in the server (wait event), that handles TCP/IP sockets on Oracle 10.2+; (packages -> UTL_TCP, UTP_SMTP, UTP_HTTP, ...)

When there is a network delay between application server and database server we see this event mostly. In our case we have found a report in an application which is generating huge data is the cause for this wait event.

This wait event some ties relates to mail server was down and the procedure tries to open a new connection with the SMTP server and it takes 75 /20 seconds to timeout on various operating systems.

On 10g Release 2 there is bug reported by oracle support BUG:5490208 - TIME WAIT TCP SOCKET KGAS

Tuesday, May 24, 2011

AWR Top 5 Timed Events - resmgr: cpu quantum

resmgr: cpu quantum -- It shows that the sessions are waiting for CPU allocation.



This event occurs when the resource manager is enabled and is throttling CPU consumption. To reduce the occurrence of this wait event, increase the CPU allocation for the sessions’s current consumer group. There are many bugs in 10g related to Resource Manager.

Wait event 'resmgr: cpu quantum' is appearing in the top 5 wait events.

First of all it is important to understand that the 'resmgr:cpu quantum' is a normal wait event used by Resource Manager to control CPU distribution. Whenever Resource Manager is in use this event will be seen in the database. It becomes a problem when it is one the top waiter events in the database.

I will try to illustrate it with an example. Let assume the following multi-level plan.

SYS_GROUP 100% CPU_Level 1 - user TEST_SYS
OPER_GROUP 100% CPU_Level 2 - user TEST_OPER
LOW_GROUP 100% CPU_Level 3 - user TEST_LOW

The following query will give you the timings for wait event 'resmgr:cpu quantum' on a user-basis

select s.username, se.event, sum(total_waits) total_waits, sum(time_waited) total_time_waited, avg(average_wait) avg_wait from v$session_event se, v$session s where se.event = 'resmgr:cpu quantum' and se.sid = s.sid group by s.username, se.event;

USERNAME EVENT TOTAL_WAITS TOTAL_TIME_WAITED AVG_WAIT
---------- -------------------- ----------- ------------------ --------
TEST_SYS resmgr:cpu quantum 13 11 0.88
TEST_OPER resmgr:cpu quantum 26 108 4.17
TEST_LOW resmgr:cpu quantum 8 62019 7752.33

This output clearly illustrate that user TEST_SYS, although it also has timings for the 'resmgr:cpu quantum', the total time waited is very low. Our next group TEST_OPER who receives 100% CPU at level 2 is getting more waits and the waits last longer. And our third group TEST_LOW is not getting that much 'resmgr:cpu quantum' wait calls, basically because there is an intelligent system behind the polling, but as the output clearly shows thet wait time is much-much higher.

So, when you receive waits for 'resmgr:cpu quantum'

1. Verify the AWR/statspack reports to see whether it is appearing as a top waiter ?

2. Verify the wait event on a user basis to see which user has the most wait timings and compare this to the consumer group directives. There may be a very logical explanation.

3. If the above is verified, check the following

3.1 NUMA architecture ?

Starting with 10.2.0.4 NUMA is enabled by default in the database. Wo when we detect a NUMA enabled machine this will automatically be enabled at the Oracle level as well, however if the system has not specifically been setup and tuned to make use of this architecture then the Resource Manager may cause unnecessary waits for 'resmgr:cpu quantum'

Download and apply patch for bug:8199533 to disable NUMA optimization at the database layer .

As a short term solution or by means of test, you can enable the following initialization parameter:
_enable_NUMA_optimization=FALSE

However, Oracle Customer Support recommended using fix for BUG:8199533 to disable NUMA. The patch is rolling upgradeable.

3.2 Version pre-11gR2 ?

BUG:7510766: Resource Manager is over throttling

This is practically a pre-requistite for most versions .Fixed in 11g Release2 and planned to be included in patchset 10.2.0.5, all lower versions require patching

3.3 version pre-11gR1 ?

Bug:8221960: Waits for "RESMGR CPU QUANTUM"

Make sure to have a merge fix with the above bug (#7510766) in 3.1
3.4 Is the wait event observed during the time RMAN is in use ?

Bug:6874858: Poor performance with Resource Manager when RMAN is running

Fixed in 11g Release2 and planned to be included in patchset 10.2.0.5 and 11.1.0.8

3.5 Is the wait event observed during the time a datafile is added ?

Bug:4602661: Adding a datafile hangs other sessions and new connections with resource manager

Affects all versions pre-10.2.0.3
Typically this is associated with another wait event: 'ksfd: async disk IO'

Friday, May 6, 2011

AWR TOP 5 Timed Event Analysis - enq: TX – index contention

enq: TX – index contention







Waits for TX in mode 4 also occur when a transaction inserting a row in an index has to wait for the end of an index block split being done by another transaction.

This type of TX enqueue wait corresponds to the wait event enq: TX – index contention. This wait event shows one process waiting for another to complete an index block split.

If there is an index on a column that is being populated from a call to sequence.nextval on insert then you will most likely see many of these waits if your system inserts into the table very frequently from a number of concurrent sessions.

One solution for this problem is to identify which index is waiting for and try to create reverse key index if it is a single instance. If it is RAC then one has to increase the sequence cache value to few hundreds to thousands so that it reduces the competition for the same lead node across participating instances in RAC.


In our case we could able to get rid of this by increasing the Cache value for sequences where we have indexes.


Friday, April 29, 2011

AWR TOP 5 Timed Event Analysis - Global Cache Wait Events

The Global Cache Service is the controlling process that implements Cache Fusion. It maintains the block mode for blocks in the global role. It is responsible for block transfers between instances. The Global Cache Service employs various background processes such as the Global Cache Service Processes (LMSn) and Global Enqueue Service Daemon (LMD)


Global cache (“gc” ) events and statistics Indicate that Oracle searches the cache hierarchy to find data fast as “normal” as an IO ( e.g. db file sequential read )

GC events tagged as “busy” or “congested” consuming a significant amount of database time should be investigated. At first, assume a load or IO problem on one or several of the cluster nodes.


  

 
 
 
 
 
All Global Cache Events will follow the following format:


RAC wait events are grouped in a category called “Cluster Wait Class” characterized as Current or CR.

• Current - blocks read into memory for the first time
• Consistent Read (CR) - denotes block for read access

The following wait events shows that the remotely cached blocks were shipped to the local Instance without having been busy, pinned or requiring a log flush. In a simple way buffer requests and received for read or write

gc current block 2-way
gc current block 3-way
gc cr block 2-way
gc cr block 3-way

GC cr/current block congested
  • Repeated requests by foreground processes, not serviced by LMS
  • Indicates LMS not able to keep up
  • Queue lengths & scheduling delays in OS, can cause LMS delays

GC cr/current block busy

  •  Delay for some reason, before block sent to requestor

 GC current grant busy

  •  Permission to access the block granted, but blocked by other requests ahead of it

 GC cr/current block request

  • Wait time, cr or current block is being retrieved 
How do we intrepet the AWR further for the GC Wait Event problems.

     
    Check where most of the time in the database is spend (“Top 5 Timed Events” )
    Check whether gc events are “busy”, “congested”  --  Check the avg wait time  --  Drill down the AWR further for finding the top wait events --  SQL with highest cluster wait time  --- Segment Statistics with highest block transfers
    .
Interconnect issues must be fixed first


If IO wait time is dominant , fix IO issues

At this point, performance may already be good

Fix “bad” plans

Fix serialization

Fix schema 

Thursday, April 21, 2011

AWR Analysis - Parse CPU to Parse Elapsd %

Under AWR’s Instance Efficiency Percentages - Parse CPU to Parse Elapsd % is one area which is more confusing and clear information will not be available. Information below talks clearly on how to we interpret the ratio.

• If you spend 1 CPU second on CPU to parse but total elapsed is 5 second wall clock time then it means you are waiting on some resources to complete the parsing.

• Ideally Parse Elapsed must be equal to Parse CPU, i.e., only CPU time is used for parsing. In that case the ratio is 100%. If wait time is more than the ratio will be less.


 
(8879/110582)*100=8.03%
What does it mean and how it is being interpreted
• Parse CPU to Parse Elapsd %: 8.03
• It is percentage. 8.03% means .0803
• If you divide it by 1 then 1/.0803 = 12.45
• Which means 12.45 second (wall clock time) must be elapsed for every cpu second for parsing. Its not   
   good.
• It represents resource contention while parsing.Low Value for this ratio is an indicator of latching problem. Investigate the latch sections in AWR report for contention on library cache and shared pool latches.