SlideShare a Scribd company logo
1 of 7
How To Automatic Kill Inactive Sessions using
Resource Manager (Doc ID 1935739.1)
To
Bottom
In this Document
Goal
Solution
References
APPLIES TO:
Oracle Database - Enterprise Edition - Version 11.2.0.1 to 12.1.0.2 [Release 11.2 to
12.1]
Information in this document applies to any platform.
***Checked for relevance on 23-May-2016***
GOAL
Database server crashed after memory on server used by inactive sessions
SOLUTION
The Following Example used to illustrate the scenario for User SH , please Review and
modify whatever needed
to confirm Automatic Kill of the Huge number of Inactive Sessions after a period of Idle
Time .
1.CREATE THE PLAN
begin
dbms_resource_manager.create_pending_area();
end;
/
begin
dbms_resource_manager.create_plan( plan => 'TEST_PLAN', comment =>
'Resource plan/method for Idle
time kill sessions');
end;
/
2.CREATE THE CONSUMER GROUPS
begin
dbms_resource_manager.create_consumer_group( consumer_group =>
'LONG_RUNNING',
comment =>'Privileged Users');
dbms_resource_manager.create_consumer_group( consumer_group =>
'SHORT_RUNNING',
comment => 'Under Privileged Users');
end;
/
3.CREATE DIRECTIVES FOR THE PLAN
begin
dbms_resource_manager.create_plan_directive( plan => 'TEST_PLAN',
group_or_subplan =>
'LONG_RUNNING', comment => 'Limit idle time to 5 minutes',
max_idle_time => 300);
dbms_resource_manager.create_plan_directive( plan => 'TEST_PLAN',
group_or_subplan =>
'SHORT_RUNNING', comment => 'Limit idle time to 1 minute',
max_idle_time => 60);
dbms_resource_manager.create_plan_directive( plan => 'TEST_PLAN',
group_or_subplan =>
'OTHER_GROUPS', comment => 'Limit idle time to 1 Hour', max_idle_time
=> 3600);
end;
/
4.VALIDATE AND SUBMIT THE PLAN
begin
dbms_resource_manager.validate_pending_area();
end;
/
begin
dbms_resource_manager.submit_pending_area();
end;
/
5.ALLOW CONSUMER GROUP SWITCHING
begin
dbms_resource_manager_privs.grant_switch_consumer_group(grantee_name
=> 'SYSTEM',
consumer_group => 'LONG_RUNNING', grant_option => FALSE);
dbms_resource_manager_privs.grant_switch_consumer_group(grantee_name
=> 'SH',
consumer_group => 'SHORT_RUNNING', grant_option => FALSE);
end;
/
6.ASSIGN DATABASE USERS A DEFAULT INITIAL CONSUMER GROUP AT CONNECTION
TIME
For Example :
A)User SYSTEM is made member of the group LONG_RUNNING
B)User SH is made member of the group SHORT_RUNNING
begin
dbms_resource_manager.create_pending_area();
end;
/
begin
dbms_resource_manager.set_initial_consumer_group( user => 'SYSTEM',
consumer_group => 'LONG_RUNNING');
dbms_resource_manager.set_initial_consumer_group( user => 'SH',
consumer_group => 'SHORT_RUNNING');
end;
/
begin
dbms_resource_manager.validate_pending_area();
end;
/
begin
dbms_resource_manager.submit_pending_area();
end;
/
7.MAKE THE NEW PLAN THE ACTIVE ONE FOR THE DATABASE
SQL> alter system set resource_manager_plan=’TEST_PLAN’;
This query will show the sessions that are killed when the idle time thresholds set for
the plan are crossed.
SQL> select NAME, ACTIVE_SESSIONS_KILLED, IDLE_SESSIONS_KILLED
FROM V$RSRC_CONSUMER_GROUP WHERE NAME='SHORT_RUNNING';
SQL>select SID,MODULE,STATUS
from V$session where USERNAME='SH';
SID MODULE
---------- ----------------------------------------------------------------
STATUS
--------
365 SQL*Plus
KILLED
Testing for the release of resources :
From Session 1:
SQL>conn sh/sh ;
Connected.
SQL>create table con_tab ( a varchar2(34));
Table created.
15:11:40 SQL>lock table con_tab in exclusive mode ;
Table(s) Locked.
From Session 2
SQL>select SID,MODULE,STATUS
from V$session where USERNAME='SH'
15:12:04 SYS@Farag11203>/
SID MODULE
---------- -----------------------------------------------------------
-----
STATUS
--------
5 SQL*Plus
INACTIVE
15:12:28 SYS@Farag11203>/
SID MODULE
---------- -----------------------------------------------------------
-----
STATUS
--------
5 SQL*Plus
KILLED
15:18:26 SQL>conn sh/sh
Connected.
15:18:35 SQL>alter table con_tab add c number;
Table altered.
From the above Test for sh session that was locking table con_tab in exclusive mode on
session 1.
the session have a status of inactive for more than 60 seconds (idle)
after the seconds it changed to a status of KILLED and afterwards a conenction
using session 2 to sh/sh would be able to acquire exclusive reourse on the same table ,
which confirmed that the lock table resources has been released .
To delete the plan .
Deleting a Plan
The DELETE_PLAN procedure deletes the specified plan as well as all the plan directives
associated with it. The pending area must be created first, and then submitted after the plan is
deleted.
The following PL/SQL block deletes the great_bread plan and its directives.
BEGIN
DBMS_RESOURCE_MANAGER.DELETE_PLAN(PLAN => 'great_bread');
END;
/
+
To delete consumer group
DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP (
consumer_group IN VARCHAR2);
please refer the below
http://docs-uat1.us.oracle.com/cd/E11882_01/server.112/e25494/dbrm.htm#ADMIN11898
https://docs.oracle.com/cd/A91202_01/901_doc/appdev.901/a89852/dbms_r9a.htm
Thanks & Regards,
Shekar Tuduru,
Shift time: 7 AM to 3:30 PM (IST),
Desk Phone: +91 80 41072313,
Oracle Customer Support.
If you need assistance during my off-shift hours, please call the Oracle HUB and request for
reassignment of this SR.
Contact number of HUB : http://www.oracle.com/support/contact.html (1.800.223.1711)

More Related Content

Similar to How To Automatically Kill Inactive Sessions using Resource Manager

Oracle audit and reporting in one hour or less
Oracle audit and reporting in one hour or lessOracle audit and reporting in one hour or less
Oracle audit and reporting in one hour or lessLeon Rzhemovskiy
 
12c db upgrade from 11.2.0.4
12c db upgrade from 11.2.0.412c db upgrade from 11.2.0.4
12c db upgrade from 11.2.0.4uzzal basak
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
Odv oracle customer_demo
Odv oracle customer_demoOdv oracle customer_demo
Odv oracle customer_demoViaggio Italia
 
Oracle database 12.2 new features
Oracle database 12.2 new featuresOracle database 12.2 new features
Oracle database 12.2 new featuresAlfredo Krieg
 
Basic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition PresentationBasic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition PresentationN/A
 
LVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11gLVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11gMaris Elsins
 
Pluggable database tutorial
Pluggable database tutorialPluggable database tutorial
Pluggable database tutorialOsama Mustafa
 
active_session_history_oracle_performance.ppt
active_session_history_oracle_performance.pptactive_session_history_oracle_performance.ppt
active_session_history_oracle_performance.pptcookie1969
 
Oracle 12c Automatic Data Optimization (ADO) - ILM
Oracle 12c Automatic Data Optimization (ADO) - ILMOracle 12c Automatic Data Optimization (ADO) - ILM
Oracle 12c Automatic Data Optimization (ADO) - ILMMonowar Mukul
 
2008 Collaborate IOUG Presentation
2008 Collaborate IOUG Presentation2008 Collaborate IOUG Presentation
2008 Collaborate IOUG PresentationBiju Thomas
 
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
NoCOUG_201411_Patel_Managing_a_Large_OLTP_DatabaseNoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
NoCOUG_201411_Patel_Managing_a_Large_OLTP_DatabaseParesh Patel
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerAndrejs Vorobjovs
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfPraveenPolu1
 
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobsMonowar Mukul
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 

Similar to How To Automatically Kill Inactive Sessions using Resource Manager (20)

Oracle audit and reporting in one hour or less
Oracle audit and reporting in one hour or lessOracle audit and reporting in one hour or less
Oracle audit and reporting in one hour or less
 
12c db upgrade from 11.2.0.4
12c db upgrade from 11.2.0.412c db upgrade from 11.2.0.4
12c db upgrade from 11.2.0.4
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Odv oracle customer_demo
Odv oracle customer_demoOdv oracle customer_demo
Odv oracle customer_demo
 
Oracle database 12.2 new features
Oracle database 12.2 new featuresOracle database 12.2 new features
Oracle database 12.2 new features
 
Basic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition PresentationBasic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition Presentation
 
LVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11gLVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11g
 
Sherlock holmes for dba’s
Sherlock holmes for dba’sSherlock holmes for dba’s
Sherlock holmes for dba’s
 
Pluggable database tutorial
Pluggable database tutorialPluggable database tutorial
Pluggable database tutorial
 
Firebird
FirebirdFirebird
Firebird
 
active_session_history_oracle_performance.ppt
active_session_history_oracle_performance.pptactive_session_history_oracle_performance.ppt
active_session_history_oracle_performance.ppt
 
Oracle 12c Automatic Data Optimization (ADO) - ILM
Oracle 12c Automatic Data Optimization (ADO) - ILMOracle 12c Automatic Data Optimization (ADO) - ILM
Oracle 12c Automatic Data Optimization (ADO) - ILM
 
2008 Collaborate IOUG Presentation
2008 Collaborate IOUG Presentation2008 Collaborate IOUG Presentation
2008 Collaborate IOUG Presentation
 
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
NoCOUG_201411_Patel_Managing_a_Large_OLTP_DatabaseNoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource Manager
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdf
 
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 

Recently uploaded

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

How To Automatically Kill Inactive Sessions using Resource Manager

  • 1. How To Automatic Kill Inactive Sessions using Resource Manager (Doc ID 1935739.1) To Bottom In this Document Goal Solution References APPLIES TO: Oracle Database - Enterprise Edition - Version 11.2.0.1 to 12.1.0.2 [Release 11.2 to 12.1] Information in this document applies to any platform. ***Checked for relevance on 23-May-2016*** GOAL Database server crashed after memory on server used by inactive sessions SOLUTION The Following Example used to illustrate the scenario for User SH , please Review and modify whatever needed to confirm Automatic Kill of the Huge number of Inactive Sessions after a period of Idle Time . 1.CREATE THE PLAN begin dbms_resource_manager.create_pending_area(); end; / begin
  • 2. dbms_resource_manager.create_plan( plan => 'TEST_PLAN', comment => 'Resource plan/method for Idle time kill sessions'); end; / 2.CREATE THE CONSUMER GROUPS begin dbms_resource_manager.create_consumer_group( consumer_group => 'LONG_RUNNING', comment =>'Privileged Users'); dbms_resource_manager.create_consumer_group( consumer_group => 'SHORT_RUNNING', comment => 'Under Privileged Users'); end; / 3.CREATE DIRECTIVES FOR THE PLAN begin dbms_resource_manager.create_plan_directive( plan => 'TEST_PLAN', group_or_subplan => 'LONG_RUNNING', comment => 'Limit idle time to 5 minutes', max_idle_time => 300); dbms_resource_manager.create_plan_directive( plan => 'TEST_PLAN', group_or_subplan => 'SHORT_RUNNING', comment => 'Limit idle time to 1 minute', max_idle_time => 60); dbms_resource_manager.create_plan_directive( plan => 'TEST_PLAN', group_or_subplan => 'OTHER_GROUPS', comment => 'Limit idle time to 1 Hour', max_idle_time => 3600); end; / 4.VALIDATE AND SUBMIT THE PLAN begin dbms_resource_manager.validate_pending_area(); end;
  • 3. / begin dbms_resource_manager.submit_pending_area(); end; / 5.ALLOW CONSUMER GROUP SWITCHING begin dbms_resource_manager_privs.grant_switch_consumer_group(grantee_name => 'SYSTEM', consumer_group => 'LONG_RUNNING', grant_option => FALSE); dbms_resource_manager_privs.grant_switch_consumer_group(grantee_name => 'SH', consumer_group => 'SHORT_RUNNING', grant_option => FALSE); end; / 6.ASSIGN DATABASE USERS A DEFAULT INITIAL CONSUMER GROUP AT CONNECTION TIME For Example : A)User SYSTEM is made member of the group LONG_RUNNING B)User SH is made member of the group SHORT_RUNNING begin dbms_resource_manager.create_pending_area(); end; / begin dbms_resource_manager.set_initial_consumer_group( user => 'SYSTEM', consumer_group => 'LONG_RUNNING'); dbms_resource_manager.set_initial_consumer_group( user => 'SH', consumer_group => 'SHORT_RUNNING'); end; / begin dbms_resource_manager.validate_pending_area(); end;
  • 4. / begin dbms_resource_manager.submit_pending_area(); end; / 7.MAKE THE NEW PLAN THE ACTIVE ONE FOR THE DATABASE SQL> alter system set resource_manager_plan=’TEST_PLAN’; This query will show the sessions that are killed when the idle time thresholds set for the plan are crossed. SQL> select NAME, ACTIVE_SESSIONS_KILLED, IDLE_SESSIONS_KILLED FROM V$RSRC_CONSUMER_GROUP WHERE NAME='SHORT_RUNNING'; SQL>select SID,MODULE,STATUS from V$session where USERNAME='SH'; SID MODULE ---------- ---------------------------------------------------------------- STATUS -------- 365 SQL*Plus KILLED Testing for the release of resources : From Session 1: SQL>conn sh/sh ; Connected.
  • 5. SQL>create table con_tab ( a varchar2(34)); Table created. 15:11:40 SQL>lock table con_tab in exclusive mode ; Table(s) Locked. From Session 2 SQL>select SID,MODULE,STATUS from V$session where USERNAME='SH' 15:12:04 SYS@Farag11203>/ SID MODULE ---------- ----------------------------------------------------------- ----- STATUS -------- 5 SQL*Plus INACTIVE 15:12:28 SYS@Farag11203>/ SID MODULE ---------- ----------------------------------------------------------- ----- STATUS -------- 5 SQL*Plus KILLED 15:18:26 SQL>conn sh/sh Connected. 15:18:35 SQL>alter table con_tab add c number; Table altered.
  • 6. From the above Test for sh session that was locking table con_tab in exclusive mode on session 1. the session have a status of inactive for more than 60 seconds (idle) after the seconds it changed to a status of KILLED and afterwards a conenction using session 2 to sh/sh would be able to acquire exclusive reourse on the same table , which confirmed that the lock table resources has been released . To delete the plan . Deleting a Plan The DELETE_PLAN procedure deletes the specified plan as well as all the plan directives associated with it. The pending area must be created first, and then submitted after the plan is deleted. The following PL/SQL block deletes the great_bread plan and its directives. BEGIN DBMS_RESOURCE_MANAGER.DELETE_PLAN(PLAN => 'great_bread'); END; / + To delete consumer group DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP ( consumer_group IN VARCHAR2); please refer the below http://docs-uat1.us.oracle.com/cd/E11882_01/server.112/e25494/dbrm.htm#ADMIN11898 https://docs.oracle.com/cd/A91202_01/901_doc/appdev.901/a89852/dbms_r9a.htm Thanks & Regards, Shekar Tuduru, Shift time: 7 AM to 3:30 PM (IST),
  • 7. Desk Phone: +91 80 41072313, Oracle Customer Support. If you need assistance during my off-shift hours, please call the Oracle HUB and request for reassignment of this SR. Contact number of HUB : http://www.oracle.com/support/contact.html (1.800.223.1711)