A discussion of Dead Connection Detection, Resource Limits, V$SESSION, V$PROCESS and OS processes (文档 ID 601605.1) 转到底部

In this Document

Goal
  Solution
  References

APPLIES TO:

Oracle Database - Enterprise Edition - Version 8.0.3.0 and later
Oracle Net Services - Version 9.2.0.1 and later
Information in this document applies to any platform.
***Checked for relevance on 02-Sep-2016***

GOAL

Discuss what can be expected when implementing Dead Connection Detection (DCD) along with Database Resource Limits with user Profiles, inactive sessions and the effects on V$SESSION, V$PROCESS and OS processes

SOLUTION

Dead Connection Detection (DCD) 

These are previously valid connections with the database but the connection between the client and server processes has terminated abnormally.
Examples of a dead connection:
- A user reboots/turns-off their machine without logging off or disconnecting from the database.
- A network problem prevents communication between the client and the server.

In these cases, the shadow process running on the server and the session in the database may not terminate.

Implemented by 
      * adding SQLNET.EXPIRE_TIME = <MINUTES> to the sqlnet.ora file 

With DCD is enabled, the Server-side process sends a small 10-byte packet to the client process after the duration of the time interval specified in minutes by the SQLNET.EXPIRE_TIME parameter.

If the client side connection is still connected and responsive, the client sends a response packet back to the database server, resetting the timer..and another packet will be sent when next interval expires (assuming no other activity on the connection).

If the client fails to respond to the DCD probe packet
     * the Server side process is marked as a dead connection and 
     * PMON performs the clean up of the database processes / resources
     * The client OS processes are terminated

NOTE: SQLNET.RECV_TIMEOUT can be set on the SERVER side sqlnet.ora file. This will set a timeout for the server process 
                 to wait for data from the client process. 

Inactive Sessions:

These are sessions that remain connected to the database with a status in v$session of INACTIVE.
Example of an INACTIVE session:
- A user starts a program/session, then leaves it running and idle for an extended period of time.

Database Resource Limits (using user profiles) 

Implemented by 
     * Setting RESOURCE_LIMIT = TRUE in the database startup parameter file (spfile or pfile) 
     * Creating or modifying existing user profiles (DBA_PROFILES) to have one or more resource limit
     * Assigning a profile to a user whose resources are wished to be limited 

It could happen that if the idle_time has been set on the DEFAULT profile, this can lead to an MTS dispatchers being set to 'sniped' and then getting 'cleaned up' via the shell script. The removal of the dispatcher will result in other sessions 'dying' .In that case, If you are to implement resource limits, may be advisable to create new profiles
that be assigned to users and not to change the characteristics of DEFAULT.
Alternatively, if you do change DEFAULT, ensure that all the properties that you
have affected have been fully tested in a development environment.

When a resource limit is exceeded (for example IDLE_TIME) ... PMON does the following 
     * Mark the V$SESSION as SNIPED 
     * Clean up the database resources for the session
     * Remove the V$SESSION entry

When a resource limit is exceeded (for example IDLE_TIME) ... PMON marks the session as SNIPED in V$SESSION.  Then, AFTER the SNIPED session tries to execute any SQL statement, its database resources are cleaned up and its V$SESSION entry is removed.

Resource Manager

Resource manager plans can be created to kill inactive sessions with high idle time. Refer to How To Automatic Kill Inactive Sessions using Resource Manager (Doc ID 1935739.1). This document contains the details with an example. You can customize the plan directives as per your requirement.

In this case, once the inactive time goes beyond the specified MAX_IDLE_TIME, PMON marks the session as KILLED. When this KILLED later tries to execute any SQL statement, its database resources are cleaned up and its V$SESSION entry is removed.

It is strongly recommended that both DCD and Resource Limits with Profiles be implemented in order to clean up resources at both the database and OS level

This combination will not clean up IDLE / ABANDONED / INACTIVE connections (OS processes) as these sessions still have active clients

For this case we will see that :
     * PMON has cleaned up the V$SESSION entries .. but both the OS processes and the V$PROCESS entries will still exist 
     * SQLNET will continue to be able to send the 10 byte packet successfully until the session is logged off 

This condition can be a major problem as 
     * The database exhausts PROCESSES and gives ORA-20 maximum number of processes <num> exceeded 
     * The OS can become exhausted due to the un needed resources consumed by the abandoned processes 

The SYMPTOMS of this condition are 
     * The database view V$PROCESS will have no corresponding V$SESSION entry 
     * An OS process / thread still exists for the SNIPED session 

The solutions to this scenario can are to cleanup the OS processes ... after which the V$PROCESS entries should be removed automatically 

Methods to cleanup OS processes:

     * UNIX : kill -x ... the OS process at the OS level (typically kill -9) 
     * UNIX:  if using a dedicated server, use the following shell script to kill the shadow process (script has been tested on Solaris, AIX, Tru64 and  HPUX):
#!/bin/sh
tmpfile=/tmp/tmp.$$
sqlplus system/manager <<EOF
spool $tmpfile
select p.spid from v\$process p,v\$session s
where s.paddr=p.addr
and s.status in ('INACTIVE,'SNIPED');
spool off
EOF
for x in `cat $tmpfile | grep "^[0123456789]"`
do
kill -9 $x
done
rm $tmpfile

NOTE: If you are running in a shared server environment, you need to be careful not to accidentally kill your dispatchers and/or shared servers. In Oracle 10.2 (or higher) a dedicated connections V$SESSION + V$PROCESS + OS Process can be cleaned up with 
ALTER SYSTEM DISCONNECT SESSION '<SID>,<SERIAL>' IMMEDIATE
At this point in versions prior to 10.2 and for shared server connections the only solution is to kill the session at the OS level (see Kill and ORAKILL above) 
     * Windows : use the orakill command .... orakill <ORACLE SID> <Thread ID> (see Note 69882.1 for details) 

On occasions we see conditions where a database session has a V$SESSION.STATUS = SNIPED ... and the entry never goes away . This condition can be achieved by implementing Database Resource Limits + Profiles without DCD and allow the database session to exceed the limit in the profile 

Summary of what was discussed here:

1) DCD initiates clean up of OS and database processes  that have disconnected / terminated abnormally
2) DCD will not initiate clean up sessions that are still connected ... but are idle / abandoned / inactive 
3) Database Resource Limits + user Profiles clean up database resources for user sessions that exceed resource limits
4) Database Resource Limits + user Profiles will not clean up OS processes
5) If DCD and Database Resource Limits + user Profiles are used in combination .. Dead Connections OS and Database Resources will be cleaned up 
6) IDLE / ABANDONED / INACTIVE sessions OS processes will not be cleaned up even if DCD and Database Resource Limits + user Profiles are used in combination ... these must be cleaned up manually

7) Resource Manager can be used to kill inactive session, which exceeds the idle time mentioned in the plan directives.

REFERENCES

NOTE:395505.1 - How to Check if Dead Connection Detection (DCD) is Enabled in 9i ,10g and 11g
NOTE:805586.1 - Troubleshooting Session Administration
NOTE:151972.1 - Dead Connection Detection (DCD) Explained
NOTE:438923.1 - How To Track Dead Connection Detection(DCD) Mechanism Without Enabling Any Client/Server Network Tracing
NOTE:1287854.1 - Troubleshooting Guide - ORA-20: Maximum Number Of Processes (%S) Exceeded
NOTE:1935739.1 - How To Automatic Kill Inactive Sessions using Resource Manager 

A discussion of Dead Connection Detection, Resource Limits, V$SESSION, V$PROCESS and OS processes (文档 ID 601605.1) 转到底部

In this Document

Goal
  Solution
  References

APPLIES TO:

Oracle Database - Enterprise Edition - Version 8.0.3.0 and later
Oracle Net Services - Version 9.2.0.1 and later
Information in this document applies to any platform.
***Checked for relevance on 02-Sep-2016***

GOAL

Discuss what can be expected when implementing Dead Connection Detection (DCD) along with Database Resource Limits with user Profiles, inactive sessions and the effects on V$SESSION, V$PROCESS and OS processes

SOLUTION

Dead Connection Detection (DCD) 

These are previously valid connections with the database but the connection between the client and server processes has terminated abnormally.
Examples of a dead connection:
- A user reboots/turns-off their machine without logging off or disconnecting from the database.
- A network problem prevents communication between the client and the server.

In these cases, the shadow process running on the server and the session in the database may not terminate.

Implemented by 
      * adding SQLNET.EXPIRE_TIME = <MINUTES> to the sqlnet.ora file 

With DCD is enabled, the Server-side process sends a small 10-byte packet to the client process after the duration of the time interval specified in minutes by the SQLNET.EXPIRE_TIME parameter.

If the client side connection is still connected and responsive, the client sends a response packet back to the database server, resetting the timer..and another packet will be sent when next interval expires (assuming no other activity on the connection).

If the client fails to respond to the DCD probe packet
     * the Server side process is marked as a dead connection and 
     * PMON performs the clean up of the database processes / resources
     * The client OS processes are terminated

NOTE: SQLNET.RECV_TIMEOUT can be set on the SERVER side sqlnet.ora file. This will set a timeout for the server process 
                 to wait for data from the client process. 

Inactive Sessions:

These are sessions that remain connected to the database with a status in v$session of INACTIVE.
Example of an INACTIVE session:
- A user starts a program/session, then leaves it running and idle for an extended period of time.

Database Resource Limits (using user profiles) 

Implemented by 
     * Setting RESOURCE_LIMIT = TRUE in the database startup parameter file (spfile or pfile) 
     * Creating or modifying existing user profiles (DBA_PROFILES) to have one or more resource limit
     * Assigning a profile to a user whose resources are wished to be limited 

It could happen that if the idle_time has been set on the DEFAULT profile, this can lead to an MTS dispatchers being set to 'sniped' and then getting 'cleaned up' via the shell script. The removal of the dispatcher will result in other sessions 'dying' .In that case, If you are to implement resource limits, may be advisable to create new profiles
that be assigned to users and not to change the characteristics of DEFAULT.
Alternatively, if you do change DEFAULT, ensure that all the properties that you
have affected have been fully tested in a development environment.

When a resource limit is exceeded (for example IDLE_TIME) ... PMON does the following 
     * Mark the V$SESSION as SNIPED 
     * Clean up the database resources for the session
     * Remove the V$SESSION entry

When a resource limit is exceeded (for example IDLE_TIME) ... PMON marks the session as SNIPED in V$SESSION.  Then, AFTER the SNIPED session tries to execute any SQL statement, its database resources are cleaned up and its V$SESSION entry is removed.

Resource Manager

Resource manager plans can be created to kill inactive sessions with high idle time. Refer to How To Automatic Kill Inactive Sessions using Resource Manager (Doc ID 1935739.1). This document contains the details with an example. You can customize the plan directives as per your requirement.

In this case, once the inactive time goes beyond the specified MAX_IDLE_TIME, PMON marks the session as KILLED. When this KILLED later tries to execute any SQL statement, its database resources are cleaned up and its V$SESSION entry is removed.

It is strongly recommended that both DCD and Resource Limits with Profiles be implemented in order to clean up resources at both the database and OS level

This combination will not clean up IDLE / ABANDONED / INACTIVE connections (OS processes) as these sessions still have active clients

For this case we will see that :
     * PMON has cleaned up the V$SESSION entries .. but both the OS processes and the V$PROCESS entries will still exist 
     * SQLNET will continue to be able to send the 10 byte packet successfully until the session is logged off 

This condition can be a major problem as 
     * The database exhausts PROCESSES and gives ORA-20 maximum number of processes <num> exceeded 
     * The OS can become exhausted due to the un needed resources consumed by the abandoned processes 

The SYMPTOMS of this condition are 
     * The database view V$PROCESS will have no corresponding V$SESSION entry 
     * An OS process / thread still exists for the SNIPED session 

The solutions to this scenario can are to cleanup the OS processes ... after which the V$PROCESS entries should be removed automatically 

Methods to cleanup OS processes:

     * UNIX : kill -x ... the OS process at the OS level (typically kill -9) 
     * UNIX:  if using a dedicated server, use the following shell script to kill the shadow process (script has been tested on Solaris, AIX, Tru64 and  HPUX):
#!/bin/sh
tmpfile=/tmp/tmp.$$
sqlplus system/manager <<EOF
spool $tmpfile
select p.spid from v\$process p,v\$session s
where s.paddr=p.addr
and s.status in ('INACTIVE,'SNIPED');
spool off
EOF
for x in `cat $tmpfile | grep "^[0123456789]"`
do
kill -9 $x
done
rm $tmpfile

NOTE: If you are running in a shared server environment, you need to be careful not to accidentally kill your dispatchers and/or shared servers. In Oracle 10.2 (or higher) a dedicated connections V$SESSION + V$PROCESS + OS Process can be cleaned up with 
ALTER SYSTEM DISCONNECT SESSION '<SID>,<SERIAL>' IMMEDIATE
At this point in versions prior to 10.2 and for shared server connections the only solution is to kill the session at the OS level (see Kill and ORAKILL above) 
     * Windows : use the orakill command .... orakill <ORACLE SID> <Thread ID> (see Note 69882.1 for details) 

On occasions we see conditions where a database session has a V$SESSION.STATUS = SNIPED ... and the entry never goes away . This condition can be achieved by implementing Database Resource Limits + Profiles without DCD and allow the database session to exceed the limit in the profile 

Summary of what was discussed here:

1) DCD initiates clean up of OS and database processes  that have disconnected / terminated abnormally
2) DCD will not initiate clean up sessions that are still connected ... but are idle / abandoned / inactive 
3) Database Resource Limits + user Profiles clean up database resources for user sessions that exceed resource limits
4) Database Resource Limits + user Profiles will not clean up OS processes
5) If DCD and Database Resource Limits + user Profiles are used in combination .. Dead Connections OS and Database Resources will be cleaned up 
6) IDLE / ABANDONED / INACTIVE sessions OS processes will not be cleaned up even if DCD and Database Resource Limits + user Profiles are used in combination ... these must be cleaned up manually

7) Resource Manager can be used to kill inactive session, which exceeds the idle time mentioned in the plan directives.

REFERENCES

NOTE:395505.1 - How to Check if Dead Connection Detection (DCD) is Enabled in 9i ,10g and 11g
NOTE:805586.1 - Troubleshooting Session Administration
NOTE:151972.1 - Dead Connection Detection (DCD) Explained
NOTE:438923.1 - How To Track Dead Connection Detection(DCD) Mechanism Without Enabling Any Client/Server Network Tracing
NOTE:1287854.1 - Troubleshooting Guide - ORA-20: Maximum Number Of Processes (%S) Exceeded
NOTE:1935739.1 - How To Automatic Kill Inactive Sessions using Resource Manager 

A discussion of Dead Connection Detection, Resource Limits, V$SESSION, V$PROCESS and OS processes的更多相关文章

  1. ORACLE的Dead Connection Detection浅析

    在复杂的应用环境下,我们经常会遇到一些非常复杂并且有意思的问题,例如,我们会遇到网络异常(网络掉包.无线网络断线).客户端程序异常(例如应用程序崩溃Crash).操作系统蓝屏.客户端电脑掉电.死机重启 ...

  2. 【论文笔记】Malware Detection with Deep Neural Network Using Process Behavior

    [论文笔记]Malware Detection with Deep Neural Network Using Process Behavior 论文基本信息 会议: IEEE(2016 IEEE 40 ...

  3. PHP 最大化资源配置 Resource Limits 错误两则

    报错信息1:PHP Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 67108888 b ...

  4. Tuxedo 超时时间控制(转贴)

    以下是转贴: TUXEDO超时控制全功略 摘要: 本<功略>集中了TUXEDO应用中,可能涉及到的所有时间参数,并分别对其进行详细描述,不但对其出处.取值等基本属性进行查证,而且,通过分析 ...

  5. oracle10g连接自动断开,报ORA-03135错误

    问题描述: oracle使用过一段时间,连接断开,报ORA-03135错误. 问题挖掘: 用pl/sql和sqlplus连接oracle,也存在该问题,确定该问题与连接方式无关. 查看服务器,发现没有 ...

  6. 数据库会话数量过多,定期清理inactive会话

    1.1现象 存在一套11.2.0.4 RAC 2节点,数据库存在5000个会话数量,其中active正在执行的会话500个,其余均为非活跃会话. 大量inactive会话过多给Oracle数据库带来什 ...

  7. ORA-3136报错

    当使用错误的用户名或密码登陆数据库时,会提示如下报错内容: bash-4.1$ sqlplus a/a@test SQL*Plus: Release 10.2.0.4.0 - Production o ...

  8. 使用 SQLNET.EXPIRE_TIME 清除僵死连接

    数据库连接的客户端异常断开后,其占有的相应并没有被释放,如从v$session视图中依旧可以看到对应的session处于inactive,且对应的服务器进程也没有释放,导致资源长时间地被占用,对于这种 ...

  9. SQL Server事务遭遇网络异常时的处理机制浅析

    SQL Server数据库中,如果应用程序正在执行一个事务的时候突然遭遇了网络异常,例如网络掉包,网络中断等,那么这个事务会怎么样? SQL Server数据库是通过什么机制来判断处理呢? 估计很多人 ...

随机推荐

  1. JS中的递归

      递归基础 递归的概念 在程序中函数直接或间接调用自己 直接调用自己 简介调用自己 跳出结构,有了跳出才有结果 递归的思想 递归的调用,最终还是要转换为自己这个函数 如果有个函数foo,如果他是递归 ...

  2. codewars.DNA题目几种解法分析(字符串替换)

    题干: 意思就是字符串替换,"A"与"C"配对,"T"与"G"配对,DNA不为空. 解法一:我的解法,用for循环遍历字 ...

  3. Python中的上下文管理器和with语句

    Python2.5之后引入了上下文管理器(context manager),算是Python的黑魔法之一,它用于规定某个对象的使用范围.本文是针对于该功能的思考总结. 为什么需要上下文管理器? 首先, ...

  4. 解决-Django使用filter过滤时间,无法获取月份的问题

    django中的filter日期查询属性有:year.month.day.week_day.hour.minute.second 但是但我在使用过滤查询是却总是无法过滤出月份,各种查资料,最后才发现是 ...

  5. JavaScript之Promise对象

    含义 Promise 是异步编程的一种解决方案,比传统的解决方案--回调函数和事件--更合理和更强大.它由社区最早提出和实现,ES6 将其写进了语言标准,统一了用法,原生提供了 Promise 对象. ...

  6. [HAOI2008]糖果传递

    题目描述 有n个小朋友坐成一圈,每人有ai个糖果.每人只能给左右两人传递糖果.每人每次传递一个糖果代价为1. 输入输出格式 输入格式: 小朋友个数n 下面n行 ai 输出格式: 求使所有人获得均等糖果 ...

  7. ●HDU 4787 GRE Words Revenge

    题链: http://acm.hdu.edu.cn/showproblem.php?pid=4787 题解: AC自动机(强制在线构造) 题目大意: 有两种操作, 一种为:+S,表示增加模式串S, 另 ...

  8. [LCA模版] Distance Queries

    题目描述 约翰的奶牛们拒绝跑他的马拉松,因为她们悠闲的生活不能承受他选择的长长的赛道.因此他决心找一条更合理的赛道.此题的输入于第一题相同,紧接着下一行输入一个整数K,以后K行为K个"距离问 ...

  9. 【LSGDOJ 1850】滑雪课程

    题目描述 贝西去科罗拉多州去滑雪,不过还她不太会玩,只是个能力为 1 的渣渣.贝西从 0 时刻进入滑雪场,一到 T 时刻就必须离开.滑雪场里有 N 条斜坡,第 i 条斜坡滑行一次需要 D i 分钟,要 ...

  10. ●BZOJ 1233 [Usaco2009Open] 干草堆 tower

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1233 留坑.以后再来看看. (绝望,无奈,丧心...) (这个题的证明真的很诡异啊,看得我稀 ...