Saturday, April 27, 2013

Oracle Buffer Busy Wait Event



Oracle Buffer Busy Wait Event

#LR14217
The buffer busy wait event happens when a session tries to access a block in the buffer cache but it can't because the buffer is busy, because another session is modifying the block and the contents of the block are in flux. To guarantee that the reader has a coherent image of the block with either all of the changes or none of the changes, the session modifying the block marks the block header with a flag letting other users know a change is taking place and to wait until the complete change is applied.
What causes the buffer busy wait event
The two main cases where the buffer busy wait occurs are:
  • Another session is reading the block into the buffer - this specific case has been split out into a separate read by other session wait event in 10g and higher.
  • Another session holds the buffer in an incompatible mode to our request.
While the block is being changed, the block is marked as unreadable by others. The changes that are being made should last under a few hundredths of a second, for example, a disk read should be under 20 milliseconds and a block modification should be under one millisecond. Therefore it will take a lot of buffer busy waits to cause a problem, but some examples of this are:
  • Hot block issue, such as the first block on the free list of a table, with high concurrent inserts. All users will insert into that block at the same time, until it fills up, then users start inserting into the next free block on the list, and so on.
  • Multiple users running an inefficient SQL statement performing a full table scan on the same large table at the same time. One user will read the block off disk, and the other users will wait on buffer busy waits (or read by other session in 10g and higher) for the physical I/O to complete.
Getting more information about buffer busy waits
To get more information about the SQL statement being executed and the block being waited for, trace the session or gather data from V$SESSION V$SESSION_WAIT (or just V$SESSION in 10g and higher):
SELECT s.sql_hash_value, sw.p1 file#, sw.p2 block#, sw.p3 reason
FROM v$session_wait sw, v$session s
WHERE sw.event = 'buffer busy waits'
AND sw.sid = s.sid
  • P1 - file number of the data file containing the block being waited for
  • P2 - block number of the block being waited for
  • P3 - this wait is called from many different sections of Oracle code and each uses their own reason code which differ among versions
To determine the object being waited for, use the P1 (file_number) and P2 (block_number) information from the above query:

SELECT  owner , segment_name , segment_type
FROM  dba_extents
WHERE  file_id = &FileNumber
AND  &BlockNumber BETWEEN block_id AND block_id + blocks -1;

Another query that can be very useful is finding the objects in the entire Oracle database that are suffering from "buffer busy waits". The following query gives the top 10 segments:

SELECT * FROM (
   SELECT owner, object_name, subobject_name, object_type,
          tablespace_name, value
   FROM v$segment_statistics
   WHERE statistic_name='buffer busy waits'
   ORDER BY value DESC)
WHERE ROWNUM <=10

Fixing buffer busy waits

Once the database object is known, consider the following causes of contention and their solutions.
  • Undo Header - If using Automatic Undo Management (AUM), increase the size of the undo tablespace. If not using AUM, add more rollback segments.
  • Undo Block - If using AUM, increase size of the undo tablespace. If not using AUM, increase rollback segment sizes.
  • Data Block- Data blocks are the blocks that hold the row data in a table or index. The typical problem is that multiple sessions are requesting a block that is either not in cache or in an incompatible mode (read by other session in 10g and higher).
    • Tune inefficient queries that read too many blocks into the buffer cache. These queries could flush out blocks that may be useful for other sessions in the buffer cache. By tuning queries, the number of blocks that need to be read into the cache is minimized, reducing aging out of the existing "good" blocks in the cache.
    • Resolve Hot Blocks - If the queries above consistently return the same block or set of blocks, this is considered a hot block scenario. Delete some of the hot rows and insert them back into the table. Most of the time, the rows will be placed in a different block. The DBA may need to adjust PCTFREE and/or PCTUSED to ensure the rows are placed into a different block. Also talk with the developers to understand why a set of blocks are hot.
    • Place Table in Memory - Cache the table or keep the table in the KEEP POOL. When multiple sessions are requesting the blocks that reside in the disk, it takes too much time for a session to read it into the buffer cache. Other session(s) that need the same block will register 'buffer busy wait'. If the block is already in buffer cache, however, this possibility is eliminated. Another alternative is to increase the buffer cache size. A larger buffer cache means less I/O from disk. This reduces situations where one session is reading a block from the disk subsystem and other sessions are waiting for the block.
    • Fix Low Cardinality Indexes - Look for ways to reduce the number of low cardinality indexes, i.e. an index with a low number of unique values that could result in excessive block reads. This can especially be problematic when concurrent DML operates on table with low cardinality indexes and cause contention on a few index blocks.
  • Data Segment Header- Each segment has one header block that contains segment information, e.g. free and available block details and the highwater mark. At times, this block can be a point of contention when multiple sessions are attempting to insert/delete into/from the same table.
    • Adjust PCTFREE/PCTUSED or use ASSM - When sessions insert/delete rows into/from a block, the block must be taken out of the freelist if the PCTFREE threshold reached. When sessions delete rows from a block, the block will be put back in the freelist if PCTUSED threshold is reached. If there are a lot of blocks coming out of the freelist or going into it, all those sessions have to make that update in the freelist map in the segment header. A solution to this problem is to create multiple freelists. This will allow different insert streams to use different freelists and thus update different freelist maps. This reduces contention on the segment header block. You should also look into optimizing the PCTUSED/PCTFREE parameters so that the blocks don't go in and out of the freelists frequently. Another solution is to use ASSM which avoids the use of freelists all together.
    • Increase Extent Size - If extents are too small, Oracle must constantly allocate new extents causing contention in the extent map

WARNING: inbound connection timed out (ORA-3136)



 WARNING: inbound connection timed out (ORA-3136) 


The "WARNING: inbound connection timed out (ORA-3136)" in the alert log indicates that the client was not able to complete it's authentication within the period of time specified by parameter SQLNET.INBOUND_CONNECT_TIMEOUT.

You may also witness ORA-12170 without timeout error on the database server sqlnet.log file.This entry would also have the client address which failed to get authenticated. Some applications or JDBC thin driver applications may not have these details.

From 10.2 onwards the default value of this parameter is 60 seconds, hence if the client is not able authenticate within 60 secs , the warning would appear in the alert log and the client connection will be terminated.

This timeout restriction was introduced to combat Denial of Service (DoS) attack whereby malicious clients attempt to flood database servers with connect requests that consumes resources.


Cause:

There can be three main reasons for this error

  1. Server gets a connection request from a malicious client which is not supposed to connect to the database , in which case the error thrown is the correct behavior. You can get the client address for which the error was thrown via sqlnet log file.
  2. The server receives a valid client connection request but the client takes a long time to authenticate more than the default 60 seconds.
  3. The DB server is heavily loaded due to which it cannot finish the client logon within the timeout specified.

Diagnosis: 

The default value of 60 seconds is good enough in most conditions for the database server to authenticate a client connection. If its taking longer period, then its worth checking all the below points before going for the workaround:

1. Check whether local connection on the database server is successful & quick.

2. If local connections are quick ,then check for underlying network delay with the help of your network administrator.

3. Check whether your Database performance has degraded by anyway.

4. Check alert log for any critical errors for eg, ORA-600 or ORA-7445 and get them resolved first.

Resolution:
 
These critical errors might have triggered the slowness of the database server.

As a workaround to avoid only this warning messages, you can set the parameters SQLNET.INBOUND_CONNECT_TIMEOUT and INBOUND_CONNECT_TIMEOUT_listenername
to the value more than 60.


In server side sqlnet.ora file add SQLNET.INBOUND_CONNECT_TIMEOUT

SQLNET.INBOUND_CONNECT_TIMEOUT = 120

In listener.ora file INBOUND_CONNECT_TIMEOUT_listenername

INBOUND_CONNECT_TIMEOUT_LISTENER = 110

From Oracle version 10.2.0.3 onwards the default value of INBOUND_CONNECT_TIMEOUT_ is 60 seconds. For previous releases it is zero by default.


Wednesday, April 3, 2013

SMON: Restarting fast_start parallel rollback in alert log


Error:
Today morning I check the Our Production Database Alert Log   and I found some message are shown 

Thu Apr 04 10:54:33 2013
SMON: Restarting fast_start parallel rollback
SMON: Parallel transaction recovery tried





Applies to:
Oracle Server - Enterprise Edition - Version 10.2.0.2 to 11.2.0.2 [Release 10.2 to 11.2]
Information in this document applies to any platform.
***Checked for relevance on 24-Apr-2012***
Symptoms
After canceling a delete operation, then, physically killing the OS process and performing a truncate on the same table, the following is reported in the alert.log and trace file:
ALERT LOG
"SMON: Restarting fast_start parallel rollback"

TRACE
Parallel transaction recovery caught exception 12801
Parallel transaction recovery caught exception 30317
NOTE: Trace files are SMON traces found in bdump directory.
Cause
Parallel UNDO operation cannot find record previously deleted.

The error indicates that Oracle is trying to apply some parallel undo and checks to see if the object or record exists, if not, this error is raised.
This generally occurs when a truncate or a delete has taken place and the transaction is canceled.
If another delete or truncate then is issued, if the record is no longer in the UNDO, then you will receive this error.
Solution
No action is required. No corruption applies unless the error is followed by other internal errors on the object.

Thanks.
Happy Reading...
 

Wednesday, October 3, 2012

ORA-00018 maximum number of sessions exceeded

ORA-00018 maximum number of sessions exceeded
Cause: All session state objects are in used.
Action: Increase the value of the SESSIONS initialization parameter.

ORA-00018 comes under Oracle Database Server Messages. These messages are generated
by the Oracle database server when running any Oracle program.

How to increase SESSION initialization parameter ? Here Given it below

1. Login as sysdba
 C:\>sqlplus /nolog
 SQL> conn / as sysdba


2. Check Current Setting of Parameters
SQL> show parameter sessions
 SQL> show parameter processes
SQL> show parameter transactions


3. If you are planning to increase "sessions" parameter you should also plan to increase
"processes and "transactions" parameters.
A basic formula for determining  these parameter values is as follows:
   
  processes=x
  sessions=x*1.1+5
  transactions=sessions*1.1

 
4. These paramters can't be modified in memory. You have to modify the spfile only
(scope=spfile) and bounce the instance.
SQL> alter system set processes=500 scope=spfile;
 

SQL> alter system set sessions=555 scope=spfile;
 

 SQL> alter system set transactions=610 scope=spfile;
 

SQL> Shutdown immediate;

If Database shutdown taken longtime  then you can apply shutdown abort command
SQL> shutdown abort
 

SQL> startup
After successful database open then again check the above modified parameter value are update yes or not. If parameter value are updated then create new pfile  on oracle home pfile location for last updated modified oracle initialization parameter .

5. Create pfile on oracle home pfile location
SQL> create pfile ='d:\pfilelocation' from spfile;

Enjoy.........

Tuesday, May 29, 2012

Different Date Format show command on Linux

Display the date in mm-dd-yy format
$date +"%m-%d-%y"

Output:
02-29-12

Dispaly the date in mm-dd-yyyy format
$date +"%m-%d-%Y"

Output:
02-29-2012

display date as mm/dd/yy format:
$date +"%D"

Output:
02/29/12

OR

display date as mm/dd/yyyy format:
$date +"%m/%d/%Y"

Output:
02/29/2012

Wednesday, June 22, 2011

Oracle Enterprise Manager (emctl Utility) Command in Windows XP


Oracle Enterprise Manager (emctl Utility) Command
=====================================

Command line utility of Oracle Enterprise Manager Console called Enterprise Manager Control. Using emctl command Enterprise Manager Control utility invoked. For managing Oracle Enterprise Manager emctl command is very useful. We are able to start & stop Oracle Enterprise Manager console. We are able to start & stop Oracle Management Server as well as Oracle Management Agent. Even we are able to start and stop Oracle Application server control using Enterprise Manager Control utility.
Oracle Management Agent is managing and administrating Oracle database in Grid environment.  Using Oracle Management Agent you can run jobs, start listener, start instance, stop listener, stop instances.  Oracle Management Agent resides at every Oracle instances, application servers. Hence Management Agent is key feature of Oracle Enterprise Manager Grid.
Usage of Enterprise Manager Control utility:
Emctl {start | stop| status}  (dbconsole | oms | agent | iasconsole)
Using start; you can start dbconsole, oms, agent, iasconsole
Using stop; you can stop dbconsole, oms, agent, iasconsole
Using status; you can check status of dbconsole, oms, agent, iasconsole.
Terminology:
Dbconsole is Database Control console.
OMS is Oracle Management Server.
Agent is Oracle Management Agent.
IASCONSOLE is Oracle Application Server Control console.
Example of Enterprise Manager Control utility:
# To start dbconsole
emctl start dbconsole
C:\>emctl start dbconsole
Oracle Enterprise Manager 10g Database Control Release 10.2.0.3.0
Copyright (c) 1996, 2006 Oracle Corporation.  All rights reserved.
http://it_mamun:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 10g Database Control ...The OracleDBConsoleORCL service is starting................
The OracleDBConsoleORCL service was started successfully.

# To Check status of dbconsole
emctl status dbconsole
C:\>emctl status dbconsole
Oracle Enterprise Manager 10g Database Control Release 10.2.0.3.0
Copyright (c) 1996, 2006 Oracle Corporation.  All rights reserved.
http://it_mamun:1158/em/console/aboutApplication
Oracle Enterprise Manager 10g is running.
------------------------------------------------------------------
Logs are generated in directory E:\oracle\product\10.2.0\db_1/it_mamun_orcl/sysman/log
C:\>

# To stop dbconsole
emctl stop dbconsole
C:\>emctl stop dbconsole
Oracle Enterprise Manager 10g Database Control Release 10.2.0.3.0
Copyright (c) 1996, 2006 Oracle Corporation.  All rights reserved.
http://it_mamun:1158/em/console/aboutApplication
The OracleDBConsoleORCL service is stopping........
The OracleDBConsoleORCL service was stopped successfully.
C:\>
# To start Management Agent
emctl start agent
 ** To start  Management Agent in command line , it will may be not start  and show given below following  message:
C:\>emctl start agent
Oracle Enterprise Manager 10g Database Control Release 10.2.0.3.0
Copyright (c) 1996, 2006 Oracle Corporation.  All rights reserved.
The service name is invalid.

More help is available by typing NET HELPMSG 2185.
So you can do tricks for  to start the dbconsole  i.e start  the dbconsole with managent agent
# To Check status of Management Agent
emctl status agent
C:\>emctl status agent
Oracle Enterprise Manager 10g Database Control Release 10.2.0.3.0
Copyright (c) 1996, 2006 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
Agent Version     : 10.1.0.5.1
OMS Version       : 10.1.0.5.0
Protocol Version  : 10.1.0.2.0
Agent Home        : E:\oracle\product\10.2.0\db_1\it_mamun_ORCL
Agent binaries    : E:\oracle\product\10.2.0\db_1
Agent Process ID  : 4720
Agent Process ID  : 4720
Agent URL         : http://it_mamun:3938/emd/main
Started at        : 2011-06-22 18:37:23
Started by user   : SYSTEM
Last Reload       : 2011-06-22 18:37:23
Last successful upload                       : 2011-06-22 18:37:41
Total Megabytes of XML files uploaded so far :     0.03
Number of XML files pending upload           :        1
Size of XML files pending upload(MB)         :     0.00
Available disk space on upload filesystem    :     8.43%
---------------------------------------------------------------
Agent is Running and Ready

#  To stop Management Agent
emctl stop agent
C:\>emctl stop agent
Oracle Enterprise Manager 10g Database Control Release 10.2.0.3.0
Copyright (c) 1996, 2006 Oracle Corporation.  All rights reserved.
This will stop the Oracle Enterprise Manager 10g Database Control process. Continue [y/n] :y
The OracleDBConsoleORCL service is stopping............
The OracleDBConsoleORCL service was stopped successfully.


C:\>

# To start Oracle Application Server control console
emctl start iasconsole
# To Check status of  iasconsole
emctl status iasconsole
# To stop Oracle Application Server control console
emctl stop iasconsole
EMCTL is very useful command line of Oracle Enterprise Manager to manage all Oracle Enterprise Manager services. Specially when we are working in Remote Oracle Support and Remote database Monitoring and managing large number of critical production Oracle databases.