关于kill session的分析
有朋友聊到了关于kill session时会话长时间没有释放,而这个小鱼一般是通过os级别的kill spid来释放session和process的,如果用oracle的kill session可能会遇见进程和会话长时间不释放,下面来做一点简单的剖析。 Session A环境: SQL> conn test/test Conn
有朋友聊到了关于kill session时会话长时间没有释放,而这个小鱼一般是通过os级别的kill spid来释放session和process的,如果用oracle的kill session可能会遇见进程和会话长时间不释放,下面来做一点简单的剖析。
Session A环境:
SQL> conn test/test
Connected.
SQL> select sid,serial#,paddr,status from v$session where sid=userenv('sid');
SID SERIAL# PADDR STATUS
---------- ---------- ---------------- --------
1147 6874 000000021A0D0A70 ACTIVE
Session B环境:
SQL> alter system kill session '1147,6874';
System altered.
SQL> select sid,serial#,paddr,status from v$session where sid=1147;
SID SERIAL# PADDR STATUS
---------- ---------- ---------------- --------
1147 6874 000000021A6A9020 KILLED
此时我们查看这个被killed的session只是将session的状态标记为killed,然后将paddr(session对应的服务器进程的地址)标记为一个虚拟的地址。
过了一段时间,我们还是在Session B环境查询被kill掉的会话,发觉这个会话依然是存在的。
SQL> select sid,serial#,paddr,status from v$session where sid=1147;
SID SERIAL# PADDR STATUS
---------- ---------- ---------------- --------
1147 6874 000000021A6A9020 KILLED
而如果我们重新在原来的session A环境做一些命令查询,此时会报出session被killed的提示
SQL> select sid,serial#,paddr,status from v$session where sid=userenv('sid');
select sid,serial#,paddr,status from v$session where sid=userenv('sid')
*
ERROR at line 1:
ORA-00028: your session has been killed
再次回到session B环境查询这个被killed的会话
SQL> select sid,serial#,paddr,status from v$session where sid=1147;
no rows selected
发现已经没有任何数据了,此时这个session对应的process也已经被pmon进程释放了。
记得小鱼处理过一个win的库,有好几百的session在报出相应的热点块现象,通过kill session后,过了很长时间所有的被killed掉session都没有释放掉,而这个可能出现的原因数据库负载太高了,pmon进程并没有去释放掉这些session,再就是在pmon进程释放之前,需要touch该session才会被pmon进程清除(这个touch的含义是必须有对该session做查询等请求递交给server端),一般建议还是通过os级别的kill来释放session和process。
那么如果我们已经在用kill session的方式killed session,但是进程依然不释放,此时我们想通过kill spid的方式来释放session和process。
SQL> select program,spid from v$process where addr in
2 (select p.addr from v$process p where p.pid
1
3 minus
4 select s.paddr from v$session s);
PROGRAM SPID
------------------------------------------------ ------------------------
oracle@dbserver (D000) 26520
oracle@dbserver (S000) 26522
oracle@dbserver (TNS V1-V3) 27932
可以通过上面的查询先查出两个视图中地址不一致的进程,这里需要注意不要kill掉系统的进程,比如这里我们就可以通过上面的查询手动kill -9 27932来释放这个session和对应的process。
SQL> !kill -9 27932
SQL> select sid,serial#,paddr,status from v$session where sid=1147;
no rows selected
此时即使我们不touch原来那个session,通过os kill的方式,sesison和process都已经马上释放了,个人也建议在维护生产环境中尽量通过os的方式来kill掉需要的session和process。
原文地址:关于kill session的分析, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











As one of the most popular short video platforms in China, Douyin has attracted a large number of users and fans. On TikTok, we often hear about fans and friends, but do you know what the difference is between TikTok fans and friends? This question will be answered in detail below. 1. What is the difference between Douyin fans and friends? On TikTok, fans are people who are interested in your content and choose to follow you. They will interact with you through likes, comments, etc. to establish a virtual connection. Friends, on the other hand, are people who know each other in real life and have real social relationships with each other. On social platforms like Douyin, the methods and depth of interactions between fans and friends may vary, but they are all important elements in building and maintaining a social network. The number of fans refers to those who follow your account

Session failure is usually caused by the session lifetime expiration or server shutdown. The solutions: 1. Extend the lifetime of the session; 2. Use persistent storage; 3. Use cookies; 4. Update the session asynchronously; 5. Use session management middleware.

How to implement data statistics and analysis in uniapp 1. Background introduction Data statistics and analysis are a very important part of the mobile application development process. Through statistics and analysis of user behavior, developers can have an in-depth understanding of user preferences and usage habits. Thereby optimizing product design and user experience. This article will introduce how to implement data statistics and analysis functions in uniapp, and provide some specific code examples. 2. Choose appropriate data statistics and analysis tools. The first step to implement data statistics and analysis in uniapp is to choose the appropriate data statistics and analysis tools.

Solution to the cross-domain problem of PHPSession In the development of front-end and back-end separation, cross-domain requests have become the norm. When dealing with cross-domain issues, we usually involve the use and management of sessions. However, due to browser origin policy restrictions, sessions cannot be shared by default across domains. In order to solve this problem, we need to use some techniques and methods to achieve cross-domain sharing of sessions. 1. The most common use of cookies to share sessions across domains

JavaScriptCookies Using JavaScript cookies is the most effective way to remember and track preferences, purchases, commissions and other information. Information needed for a better visitor experience or website statistics. PHPCookieCookies are text files that are stored on client computers and retained for tracking purposes. PHP transparently supports HTTP cookies. How do JavaScript cookies work? Your server sends some data to your visitor's browser in the form of a cookie. Browsers can accept cookies. If present, it will be stored on the visitor's hard drive as a plain text record. Now, when a visitor reaches another page on the site

Summary of case analysis of Python application in intelligent transportation systems: With the rapid development of intelligent transportation systems, Python, as a multifunctional, easy-to-learn and use programming language, is widely used in the development and application of intelligent transportation systems. This article demonstrates the advantages and application potential of Python in the field of intelligent transportation by analyzing application cases of Python in intelligent transportation systems and giving relevant code examples. Introduction Intelligent transportation system refers to the use of modern communication, information, sensing and other technical means to communicate through

Title: Analysis of the reasons and solutions for why the secondary directory of DreamWeaver CMS cannot be opened. Dreamweaver CMS (DedeCMS) is a powerful open source content management system that is widely used in the construction of various websites. However, sometimes during the process of building a website, you may encounter a situation where the secondary directory cannot be opened, which brings trouble to the normal operation of the website. In this article, we will analyze the possible reasons why the secondary directory cannot be opened and provide specific code examples to solve this problem. 1. Possible cause analysis: Pseudo-static rule configuration problem: during use

Title: Is Tencent’s main programming language Go: An in-depth analysis. As China’s leading technology company, Tencent has always attracted much attention in its choice of programming languages. In recent years, some people believe that Tencent mainly adopts Go as its main programming language. This article will conduct an in-depth analysis of whether Tencent's main programming language is Go, and give specific code examples to support this view. 1. Application of Go language in Tencent Go is an open source programming language developed by Google. Its efficiency, concurrency and simplicity are loved by many developers.
