SlideShare a Scribd company logo
1 of 43
Download to read offline
17/09/2019
1
An assassins guide to Oracle sessions
Connor McDonald
Database Advocate
Copyright © 2019 Oracle and/or its affiliates.
2
Connor McDonald
1
2
17/09/2019
2
3 3
4 4
3
4
17/09/2019
3
6
Stuff
youtube bit.ly/youtube-connor
blog bit.ly/blog-connor
twitter bit.ly/twitter-connor
400+ posts mainly on database & development
250 technical videos, new uploads every week
rants and raves on tech and the world :-)
5
6
17/09/2019
4
7
etc...
facebook bit.ly/facebook-connor
linkedin bit.ly/linkedin-connor
instagram bit.ly/instagram-connor
slideshare bit.ly/slideshare-connor
8 https://asktom.oracle.com
7
8
17/09/2019
5
The following is intended to outline our general product direction. It is intended for information purposes only,
and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or
functionality, and should not be relied upon in making purchasing decisions. The development, release,
timing, and pricing of any features or functionality described for Oracle’s products may change and remains at
the sole discretion of Oracle Corporation.
Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and prospects
are “forward-looking statements” and are subject to material risks and uncertainties. A detailed discussion of
these factors and other risks that affect our business is contained in Oracle’s Securities and Exchange
Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q under the heading
“Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website
at http://www.oracle.com/investor. All information in this presentation is current as of September 2019 and
Oracle undertakes no duty to update any statement in light of new information or future events.
Safe Harbor
10
if it's not in the documentation
- contact Support
- clarify usage before proceeding
9
10
17/09/2019
6
11
let's be honest
12
this is all about ...
11
12
17/09/2019
7
14
Apology:
gratuitous insertion
of family album pictures
into a presentation
13
14
17/09/2019
8
15
1990's
15
16
17/09/2019
9
idiot in database
18
times have changed...
17
18
17/09/2019
10
idiot in database
20
rogue session
19
20
17/09/2019
11
SQL> select sid, last_call_et, status,
3 from v$session s;
SID LAST_CALL_ET STATUS
---------- ------------ ----------
39 7376 ACTIVE
40 412 INACTIVE
44 421 INACTIVE
...
...
22
what most of us do
21
22
17/09/2019
12
23
SQL> alter system kill session ...
23
24
17/09/2019
13
25
is that our only option?
26
is that our best option?
25
26
17/09/2019
14
27
issues with "kill session"
28
issue #1 - it doesn't kill !
27
28
17/09/2019
15
SQL> alter system kill session '89,1781';
*
ERROR at line 1:
ORA-00031: session marked for kill
?
29
30
17/09/2019
16
32
the immediate solution ... isn't
31
32
17/09/2019
17
SQL> alter system kill session '89,1781' immediate;
responsive
alert.log
34
it might be doing its best
33
34
17/09/2019
18
SQL> select SES_ADDR, USED_UREC
2 from V$TRANSACTION;
SES_ADDR USED_UREC
---------------- ----------
000000008A841258 1421
SQL> /
SES_ADDR USED_UREC
---------------- ----------
000000008A841258 377
SQL> /
no rows selected.
36
it might be ghosting you
35
36
17/09/2019
19
hello?
are you there?
why wont you talk?
SQL> select s.username, p.pid, p.spid
2 from v$session s, v$process p
3 where s.paddr = p.addr
4 and s.sid = 39;
USERNAME PID SPID
-------------------- ---------- ----------
SCOTT 51 3865
37
38
17/09/2019
20
39
# kill -9 pid
40
C:> orakill MYDB pid
39
40
17/09/2019
21
42
"I have no OS access !!!"
41
42
17/09/2019
22
43
SQL> oradebug event immediate crash;
44
it still might ghost you
43
44
17/09/2019
23
SQL> select program, pid
2 from v$process
3 where upper(program) like '%PMON%';
PROGRAM PID
---------------------------------------- ----------
oracle@db192.localdomain (PMON) 2
SQL> oradebug wakeup 2
Statement processed.
46
issue #2 - you killed the session
45
46
17/09/2019
24
47
48
rogue session
47
48
17/09/2019
25
49
alternatives to kill session
50
18c
49
50
17/09/2019
26
51
aka, #1 reason to upgrade to 18c
52
SQL> alter system cancel sql '123,456';
51
52
17/09/2019
27
Upgrade
from 8.1.6
54
# kill -URG pid
53
54
17/09/2019
28
55
sys.dbms_system.set_ev(sid,serial#,10237,1,'');
sys.dbms_system.set_ev(sid,serial#,10237,0,'');
56
other supported alternatives
55
56
17/09/2019
29
SQL> begin
2 DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS
3 (
4 session_id =>sid#,
5 session_serial =>serial#,
6 consumer_group =>'CANCEL_SQL'
7 );
8 end;
58
maybe ...
57
58
17/09/2019
30
59
... you don't want to even cancel
ORA-01013: user requested cancel of current operation
59
60
17/09/2019
31
61
SQL> select sid, last_call_et, status,
3 from v$session s;
SID LAST_CALL_ET STATUS
---------- ------------ ----------
39 7376 ACTIVE
40 412 INACTIVE
44 421 INACTIVE
46 12 ACTIVE
51 9 ACTIVE
53 15 ACTIVE
58 8 ACTIVE
69 22 ACTIVE
...
80 453 INACTIVE
61
62
17/09/2019
32
SQL> oradebug setorapid nnn
SQL> oradebug suspend
SID LAST_CALL_ET STATUS
---------- ------------ ----------
39 7376 ACTIVE
40 412 INACTIVE
44 421 INACTIVE
46 12 ACTIVE
51 9 ACTIVE
53 15 ACTIVE
58 8 ACTIVE
SQL> oradebug resume
back to bad SQL
63
78
17/09/2019
33
maybe killing won't help
80
BAD
SQL
79
80
17/09/2019
34
81
bad SQL just keeps coming back...
82
19c
81
82
17/09/2019
35
83
aka, #1 reason for upgrading to 19c
84
quarantine of bad SQL
elapsed time
resource consumption
83
84
17/09/2019
36
85
error on subsequent execution
86
manually
85
86
17/09/2019
37
SQL> set feedback on sql_id
SQL> set timing on
SQL> select count(*) from scott.emp, scott.emp, scott.emp,
2 ( select 1 from dual connect by level <= 100000 );
COUNT(*)
----------
274400000
1 row selected.
SQL_ID: dcrqdagwxagth
Elapsed: 00:00:15.72
SQL> declare
2 q varchar2(30);
3 begin
4 q := dbms_sqlq.create_quarantine_by_sql_id(sql_id => 'dcrqdagwxagth');
5 end;
6 /
PL/SQL procedure successfully completed.
SQL> select count(*) from scott.emp, scott.emp, scott.emp,
2 ( select 1 from dual connect by level <= 100000 );
*
ERROR at line 1:
ORA-56955: quarantined plan used
87
88
17/09/2019
38
89
automatic via resource manager
SQL> begin
2 dbms_resource_manager.create_pending_area();
3
4 -- switch into this group before running a possibly
5 -- long running SQL statement
6
7 dbms_resource_manager.create_consumer_group(
8 CONSUMER_GROUP=>'CG_EXEC_TIME_LIMIT_CANCEL',
9 COMMENT=>'Limited execution time per statement'
10 );
11
12 -- and we need a resource plan
13
14 dbms_resource_manager.create_plan(
15 PLAN=> 'EXEC_TIME_LIMIT',
16 COMMENT=>'Kill statement after exceeding total execution time'
17 );
18
[cont]
89
90
17/09/2019
39
19 -- now create a plan directive for that special user group
20 -- to cancel current SQL if it runs for more than 'n' sec
21
22 dbms_resource_manager.create_plan_directive(
23 PLAN=> 'EXEC_TIME_LIMIT',
24 GROUP_OR_SUBPLAN=>'CG_EXEC_TIME_LIMIT_CANCEL',
25 COMMENT=>'Kill statement after exceeding total execution time',
36 SWITCH_GROUP=>'CANCEL_SQL',
37 SWITCH_TIME=>10,
38 SWITCH_ESTIMATE=>false,
39 SWITCH_FOR_CALL=> TRUE
40 );
41
42 DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA;
43
44 DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
45
46 end;
47 /
PL/SQL procedure successfully completed.
SQL> select count(*) from emp, emp, emp,
2 ( select 1 from dual connect by level <= 50000 );
COUNT(*)
----------
27440000
Elapsed: 00:00:04.11
SQL> select count(*) from emp, emp, emp,
2 ( select 1 from dual connect by level <= 1000000 );
ERROR at line 1:
ORA-00040: active time limit exceeded - call aborted
Elapsed: 00:00:12.00
91
92
17/09/2019
40
SQL> select count(*) from scott.emp, scott.emp, scott.emp,
2 ( select 1 from dual connect by level <= 100000 );
*
ERROR at line 1:
ORA-56955: quarantined plan used
94
wrap up
93
94
17/09/2019
41
95
start with aiming for better SQL
96
but if you have to kill ...
95
96
17/09/2019
42
97
... be gentle :-)
98
Ten Amazing SQL Features
Monday, September 16, 02:30 PM - 03:15 PM, Moscone South - Room 203
Proven Ways to Make Applications Slower and Less Secure [THT4796]
Tuesday, September 17, 04:30 PM - 04:50 PM, The Exchange - Theater 3
The Best Oracle Database Feature Ever Invented [THT4798]
Wednesday, September 18, 10:15 AM - 10:35 AM, The Exchange - Theater 3
Flashback - Not Just for DBAs
Wednesday, September 18, 04:00 PM - 04:45 PM, Moscone South - Room 306
PL/SQL: Still the Best Data Access Language
Thursday, September 19, 12:15 PM - 01:00 PM, Moscone South - Room 155A
97
98
17/09/2019
43
99
Have a great OpenWorld !
youtube youtube.com/c/ConnorMcDonaldOracle
blog connor-mcdonald.com
twitter @connor_mc_d
99

More Related Content

What's hot

Best Practice of Compression/Decompression Codes in Apache Spark with Sophia...
 Best Practice of Compression/Decompression Codes in Apache Spark with Sophia... Best Practice of Compression/Decompression Codes in Apache Spark with Sophia...
Best Practice of Compression/Decompression Codes in Apache Spark with Sophia...Databricks
 
Best Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupBest Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupEDB
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsEnkitec
 
Memory access tracing [poug17]
Memory access tracing [poug17]Memory access tracing [poug17]
Memory access tracing [poug17]Mahmoud Hatem
 
ProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewRené Cannaò
 
Monitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and PluginsMonitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and PluginsDatabricks
 
EnterpriseDB's Best Practices for Postgres DBAs
EnterpriseDB's Best Practices for Postgres DBAsEnterpriseDB's Best Practices for Postgres DBAs
EnterpriseDB's Best Practices for Postgres DBAsEDB
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explainedMauro Pagano
 
Mvcc (oracle, innodb, postgres)
Mvcc (oracle, innodb, postgres)Mvcc (oracle, innodb, postgres)
Mvcc (oracle, innodb, postgres)frogd
 
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOTricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOAltinity Ltd
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
 
Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!PGConf APAC
 
Spark Autotuning Talk - Strata New York
Spark Autotuning Talk - Strata New YorkSpark Autotuning Talk - Strata New York
Spark Autotuning Talk - Strata New YorkHolden Karau
 
Cosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle ServiceCosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle ServiceDatabricks
 
Cassandra Troubleshooting 3.0
Cassandra Troubleshooting 3.0Cassandra Troubleshooting 3.0
Cassandra Troubleshooting 3.0J.B. Langston
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
Oracle Database performance tuning using oratop
Oracle Database performance tuning using oratopOracle Database performance tuning using oratop
Oracle Database performance tuning using oratopSandesh Rao
 
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...Databricks
 
Spark to DocumentDB connector
Spark to DocumentDB connectorSpark to DocumentDB connector
Spark to DocumentDB connectorDenny Lee
 

What's hot (20)

Best Practice of Compression/Decompression Codes in Apache Spark with Sophia...
 Best Practice of Compression/Decompression Codes in Apache Spark with Sophia... Best Practice of Compression/Decompression Codes in Apache Spark with Sophia...
Best Practice of Compression/Decompression Codes in Apache Spark with Sophia...
 
Best Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupBest Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture Setup
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
Memory access tracing [poug17]
Memory access tracing [poug17]Memory access tracing [poug17]
Memory access tracing [poug17]
 
ProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management Overview
 
Monitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and PluginsMonitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and Plugins
 
EnterpriseDB's Best Practices for Postgres DBAs
EnterpriseDB's Best Practices for Postgres DBAsEnterpriseDB's Best Practices for Postgres DBAs
EnterpriseDB's Best Practices for Postgres DBAs
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explained
 
Mvcc (oracle, innodb, postgres)
Mvcc (oracle, innodb, postgres)Mvcc (oracle, innodb, postgres)
Mvcc (oracle, innodb, postgres)
 
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOTricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
DATADOG TIPS #1
DATADOG TIPS #1DATADOG TIPS #1
DATADOG TIPS #1
 
Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!
 
Spark Autotuning Talk - Strata New York
Spark Autotuning Talk - Strata New YorkSpark Autotuning Talk - Strata New York
Spark Autotuning Talk - Strata New York
 
Cosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle ServiceCosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle Service
 
Cassandra Troubleshooting 3.0
Cassandra Troubleshooting 3.0Cassandra Troubleshooting 3.0
Cassandra Troubleshooting 3.0
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
Oracle Database performance tuning using oratop
Oracle Database performance tuning using oratopOracle Database performance tuning using oratop
Oracle Database performance tuning using oratop
 
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
 
Spark to DocumentDB connector
Spark to DocumentDB connectorSpark to DocumentDB connector
Spark to DocumentDB connector
 

Similar to OOW19 - Killing database sessions

OOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsOOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsConnor McDonald
 
APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne Connor McDonald
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresConnor McDonald
 
OG Yatra - Flashback, not just for developers
OG Yatra - Flashback, not just for developersOG Yatra - Flashback, not just for developers
OG Yatra - Flashback, not just for developersConnor McDonald
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsConnor McDonald
 
OG Yatra - upgrading to the new 12c+ optimizer
OG Yatra - upgrading to the new 12c+ optimizerOG Yatra - upgrading to the new 12c+ optimizer
OG Yatra - upgrading to the new 12c+ optimizerConnor McDonald
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesConnor McDonald
 
12c for Developers - Feb 2014
12c for Developers - Feb 201412c for Developers - Feb 2014
12c for Developers - Feb 2014Connor McDonald
 
Most important "trick" of performance instrumentation
Most important "trick" of performance instrumentationMost important "trick" of performance instrumentation
Most important "trick" of performance instrumentationCary Millsap
 
ILOUG 2019 - Flashback, the forgotten feature
ILOUG 2019 - Flashback, the forgotten featureILOUG 2019 - Flashback, the forgotten feature
ILOUG 2019 - Flashback, the forgotten featureConnor McDonald
 
Kscope19 - Flashback: Good for Developers as well as DBAs
Kscope19 - Flashback: Good for Developers as well as DBAsKscope19 - Flashback: Good for Developers as well as DBAs
Kscope19 - Flashback: Good for Developers as well as DBAsConnor McDonald
 
OG Yatra - 25 years of hints and tips
OG Yatra - 25 years of hints and tipsOG Yatra - 25 years of hints and tips
OG Yatra - 25 years of hints and tipsConnor McDonald
 
SQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersSQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersConnor McDonald
 
ILOUG 2019 - 25 years of hints and tips
ILOUG 2019 - 25 years of hints and tipsILOUG 2019 - 25 years of hints and tips
ILOUG 2019 - 25 years of hints and tipsConnor McDonald
 
A close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesA close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesRiyaj Shamsudeen
 
ITOUG 2019 - 25 years of hints and tips
ITOUG 2019 - 25 years of hints and tipsITOUG 2019 - 25 years of hints and tips
ITOUG 2019 - 25 years of hints and tipsConnor McDonald
 
ITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c featuresITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c featuresConnor McDonald
 
APEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousAPEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousConnor McDonald
 
OOW19 - Read consistency
OOW19 - Read consistencyOOW19 - Read consistency
OOW19 - Read consistencyConnor McDonald
 

Similar to OOW19 - Killing database sessions (20)

OOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsOOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAs
 
APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL features
 
OG Yatra - Flashback, not just for developers
OG Yatra - Flashback, not just for developersOG Yatra - Flashback, not just for developers
OG Yatra - Flashback, not just for developers
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
 
OG Yatra - upgrading to the new 12c+ optimizer
OG Yatra - upgrading to the new 12c+ optimizerOG Yatra - upgrading to the new 12c+ optimizer
OG Yatra - upgrading to the new 12c+ optimizer
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest Features
 
12c for Developers - Feb 2014
12c for Developers - Feb 201412c for Developers - Feb 2014
12c for Developers - Feb 2014
 
Most important "trick" of performance instrumentation
Most important "trick" of performance instrumentationMost important "trick" of performance instrumentation
Most important "trick" of performance instrumentation
 
ILOUG 2019 - Flashback, the forgotten feature
ILOUG 2019 - Flashback, the forgotten featureILOUG 2019 - Flashback, the forgotten feature
ILOUG 2019 - Flashback, the forgotten feature
 
Kscope19 - Flashback: Good for Developers as well as DBAs
Kscope19 - Flashback: Good for Developers as well as DBAsKscope19 - Flashback: Good for Developers as well as DBAs
Kscope19 - Flashback: Good for Developers as well as DBAs
 
OG Yatra - 25 years of hints and tips
OG Yatra - 25 years of hints and tipsOG Yatra - 25 years of hints and tips
OG Yatra - 25 years of hints and tips
 
SQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersSQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX Developers
 
ILOUG 2019 - 25 years of hints and tips
ILOUG 2019 - 25 years of hints and tipsILOUG 2019 - 25 years of hints and tips
ILOUG 2019 - 25 years of hints and tips
 
A close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesA close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issues
 
ITOUG 2019 - 25 years of hints and tips
ITOUG 2019 - 25 years of hints and tipsITOUG 2019 - 25 years of hints and tips
ITOUG 2019 - 25 years of hints and tips
 
ITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c featuresITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c features
 
Oracle 11G- PLSQL
Oracle 11G- PLSQLOracle 11G- PLSQL
Oracle 11G- PLSQL
 
APEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousAPEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomous
 
OOW19 - Read consistency
OOW19 - Read consistencyOOW19 - Read consistency
OOW19 - Read consistency
 

More from Connor McDonald

Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestConnor McDonald
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQLConnor McDonald
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousConnor McDonald
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresConnor McDonald
 
OOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsOOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsConnor McDonald
 
Latin America Tour 2019 - 18c and 19c featues
Latin America Tour 2019   - 18c and 19c featuesLatin America Tour 2019   - 18c and 19c featues
Latin America Tour 2019 - 18c and 19c featuesConnor McDonald
 
Latin America tour 2019 - Flashback
Latin America tour 2019 -  FlashbackLatin America tour 2019 -  Flashback
Latin America tour 2019 - FlashbackConnor McDonald
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql featuresConnor McDonald
 
Latin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingLatin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingConnor McDonald
 
Latin America Tour 2019 - slow data and sql processing
Latin America Tour 2019  - slow data and sql processingLatin America Tour 2019  - slow data and sql processing
Latin America Tour 2019 - slow data and sql processingConnor McDonald
 
Kscope19 - Understanding the basics of SQL processing
Kscope19 - Understanding the basics of SQL processingKscope19 - Understanding the basics of SQL processing
Kscope19 - Understanding the basics of SQL processingConnor McDonald
 
18c and 19c features for DBAs
18c and 19c features for DBAs18c and 19c features for DBAs
18c and 19c features for DBAsConnor McDonald
 
APEX Connect 2019 - SQL Tuning 101
APEX Connect 2019 - SQL Tuning 101APEX Connect 2019 - SQL Tuning 101
APEX Connect 2019 - SQL Tuning 101Connor McDonald
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLConnor McDonald
 
APEX Connect 2019 - successful application development
APEX Connect 2019 - successful application developmentAPEX Connect 2019 - successful application development
APEX Connect 2019 - successful application developmentConnor McDonald
 
Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Connor McDonald
 

More from Connor McDonald (19)

Flashback ITOUG
Flashback ITOUGFlashback ITOUG
Flashback ITOUG
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolest
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on Autonomous
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL features
 
OOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsOOW19 - Slower and less secure applications
OOW19 - Slower and less secure applications
 
Latin America Tour 2019 - 18c and 19c featues
Latin America Tour 2019   - 18c and 19c featuesLatin America Tour 2019   - 18c and 19c featues
Latin America Tour 2019 - 18c and 19c featues
 
Latin America tour 2019 - Flashback
Latin America tour 2019 -  FlashbackLatin America tour 2019 -  Flashback
Latin America tour 2019 - Flashback
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql features
 
Latin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingLatin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matching
 
Latin America Tour 2019 - slow data and sql processing
Latin America Tour 2019  - slow data and sql processingLatin America Tour 2019  - slow data and sql processing
Latin America Tour 2019 - slow data and sql processing
 
ANSI vs Oracle language
ANSI vs Oracle languageANSI vs Oracle language
ANSI vs Oracle language
 
Kscope19 - Understanding the basics of SQL processing
Kscope19 - Understanding the basics of SQL processingKscope19 - Understanding the basics of SQL processing
Kscope19 - Understanding the basics of SQL processing
 
KScope19 - SQL Features
KScope19 - SQL FeaturesKScope19 - SQL Features
KScope19 - SQL Features
 
18c and 19c features for DBAs
18c and 19c features for DBAs18c and 19c features for DBAs
18c and 19c features for DBAs
 
APEX Connect 2019 - SQL Tuning 101
APEX Connect 2019 - SQL Tuning 101APEX Connect 2019 - SQL Tuning 101
APEX Connect 2019 - SQL Tuning 101
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQL
 
APEX Connect 2019 - successful application development
APEX Connect 2019 - successful application developmentAPEX Connect 2019 - successful application development
APEX Connect 2019 - successful application development
 
Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019
 

Recently uploaded

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

OOW19 - Killing database sessions

  • 1. 17/09/2019 1 An assassins guide to Oracle sessions Connor McDonald Database Advocate Copyright © 2019 Oracle and/or its affiliates. 2 Connor McDonald 1 2
  • 3. 17/09/2019 3 6 Stuff youtube bit.ly/youtube-connor blog bit.ly/blog-connor twitter bit.ly/twitter-connor 400+ posts mainly on database & development 250 technical videos, new uploads every week rants and raves on tech and the world :-) 5 6
  • 4. 17/09/2019 4 7 etc... facebook bit.ly/facebook-connor linkedin bit.ly/linkedin-connor instagram bit.ly/instagram-connor slideshare bit.ly/slideshare-connor 8 https://asktom.oracle.com 7 8
  • 5. 17/09/2019 5 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website at http://www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle undertakes no duty to update any statement in light of new information or future events. Safe Harbor 10 if it's not in the documentation - contact Support - clarify usage before proceeding 9 10
  • 7. 17/09/2019 7 14 Apology: gratuitous insertion of family album pictures into a presentation 13 14
  • 11. 17/09/2019 11 SQL> select sid, last_call_et, status, 3 from v$session s; SID LAST_CALL_ET STATUS ---------- ------------ ---------- 39 7376 ACTIVE 40 412 INACTIVE 44 421 INACTIVE ... ... 22 what most of us do 21 22
  • 12. 17/09/2019 12 23 SQL> alter system kill session ... 23 24
  • 13. 17/09/2019 13 25 is that our only option? 26 is that our best option? 25 26
  • 14. 17/09/2019 14 27 issues with "kill session" 28 issue #1 - it doesn't kill ! 27 28
  • 15. 17/09/2019 15 SQL> alter system kill session '89,1781'; * ERROR at line 1: ORA-00031: session marked for kill ? 29 30
  • 17. 17/09/2019 17 SQL> alter system kill session '89,1781' immediate; responsive alert.log 34 it might be doing its best 33 34
  • 18. 17/09/2019 18 SQL> select SES_ADDR, USED_UREC 2 from V$TRANSACTION; SES_ADDR USED_UREC ---------------- ---------- 000000008A841258 1421 SQL> / SES_ADDR USED_UREC ---------------- ---------- 000000008A841258 377 SQL> / no rows selected. 36 it might be ghosting you 35 36
  • 19. 17/09/2019 19 hello? are you there? why wont you talk? SQL> select s.username, p.pid, p.spid 2 from v$session s, v$process p 3 where s.paddr = p.addr 4 and s.sid = 39; USERNAME PID SPID -------------------- ---------- ---------- SCOTT 51 3865 37 38
  • 20. 17/09/2019 20 39 # kill -9 pid 40 C:> orakill MYDB pid 39 40
  • 21. 17/09/2019 21 42 "I have no OS access !!!" 41 42
  • 22. 17/09/2019 22 43 SQL> oradebug event immediate crash; 44 it still might ghost you 43 44
  • 23. 17/09/2019 23 SQL> select program, pid 2 from v$process 3 where upper(program) like '%PMON%'; PROGRAM PID ---------------------------------------- ---------- oracle@db192.localdomain (PMON) 2 SQL> oradebug wakeup 2 Statement processed. 46 issue #2 - you killed the session 45 46
  • 26. 17/09/2019 26 51 aka, #1 reason to upgrade to 18c 52 SQL> alter system cancel sql '123,456'; 51 52
  • 29. 17/09/2019 29 SQL> begin 2 DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS 3 ( 4 session_id =>sid#, 5 session_serial =>serial#, 6 consumer_group =>'CANCEL_SQL' 7 ); 8 end; 58 maybe ... 57 58
  • 30. 17/09/2019 30 59 ... you don't want to even cancel ORA-01013: user requested cancel of current operation 59 60
  • 31. 17/09/2019 31 61 SQL> select sid, last_call_et, status, 3 from v$session s; SID LAST_CALL_ET STATUS ---------- ------------ ---------- 39 7376 ACTIVE 40 412 INACTIVE 44 421 INACTIVE 46 12 ACTIVE 51 9 ACTIVE 53 15 ACTIVE 58 8 ACTIVE 69 22 ACTIVE ... 80 453 INACTIVE 61 62
  • 32. 17/09/2019 32 SQL> oradebug setorapid nnn SQL> oradebug suspend SID LAST_CALL_ET STATUS ---------- ------------ ---------- 39 7376 ACTIVE 40 412 INACTIVE 44 421 INACTIVE 46 12 ACTIVE 51 9 ACTIVE 53 15 ACTIVE 58 8 ACTIVE SQL> oradebug resume back to bad SQL 63 78
  • 33. 17/09/2019 33 maybe killing won't help 80 BAD SQL 79 80
  • 34. 17/09/2019 34 81 bad SQL just keeps coming back... 82 19c 81 82
  • 35. 17/09/2019 35 83 aka, #1 reason for upgrading to 19c 84 quarantine of bad SQL elapsed time resource consumption 83 84
  • 36. 17/09/2019 36 85 error on subsequent execution 86 manually 85 86
  • 37. 17/09/2019 37 SQL> set feedback on sql_id SQL> set timing on SQL> select count(*) from scott.emp, scott.emp, scott.emp, 2 ( select 1 from dual connect by level <= 100000 ); COUNT(*) ---------- 274400000 1 row selected. SQL_ID: dcrqdagwxagth Elapsed: 00:00:15.72 SQL> declare 2 q varchar2(30); 3 begin 4 q := dbms_sqlq.create_quarantine_by_sql_id(sql_id => 'dcrqdagwxagth'); 5 end; 6 / PL/SQL procedure successfully completed. SQL> select count(*) from scott.emp, scott.emp, scott.emp, 2 ( select 1 from dual connect by level <= 100000 ); * ERROR at line 1: ORA-56955: quarantined plan used 87 88
  • 38. 17/09/2019 38 89 automatic via resource manager SQL> begin 2 dbms_resource_manager.create_pending_area(); 3 4 -- switch into this group before running a possibly 5 -- long running SQL statement 6 7 dbms_resource_manager.create_consumer_group( 8 CONSUMER_GROUP=>'CG_EXEC_TIME_LIMIT_CANCEL', 9 COMMENT=>'Limited execution time per statement' 10 ); 11 12 -- and we need a resource plan 13 14 dbms_resource_manager.create_plan( 15 PLAN=> 'EXEC_TIME_LIMIT', 16 COMMENT=>'Kill statement after exceeding total execution time' 17 ); 18 [cont] 89 90
  • 39. 17/09/2019 39 19 -- now create a plan directive for that special user group 20 -- to cancel current SQL if it runs for more than 'n' sec 21 22 dbms_resource_manager.create_plan_directive( 23 PLAN=> 'EXEC_TIME_LIMIT', 24 GROUP_OR_SUBPLAN=>'CG_EXEC_TIME_LIMIT_CANCEL', 25 COMMENT=>'Kill statement after exceeding total execution time', 36 SWITCH_GROUP=>'CANCEL_SQL', 37 SWITCH_TIME=>10, 38 SWITCH_ESTIMATE=>false, 39 SWITCH_FOR_CALL=> TRUE 40 ); 41 42 DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA; 43 44 DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA(); 45 46 end; 47 / PL/SQL procedure successfully completed. SQL> select count(*) from emp, emp, emp, 2 ( select 1 from dual connect by level <= 50000 ); COUNT(*) ---------- 27440000 Elapsed: 00:00:04.11 SQL> select count(*) from emp, emp, emp, 2 ( select 1 from dual connect by level <= 1000000 ); ERROR at line 1: ORA-00040: active time limit exceeded - call aborted Elapsed: 00:00:12.00 91 92
  • 40. 17/09/2019 40 SQL> select count(*) from scott.emp, scott.emp, scott.emp, 2 ( select 1 from dual connect by level <= 100000 ); * ERROR at line 1: ORA-56955: quarantined plan used 94 wrap up 93 94
  • 41. 17/09/2019 41 95 start with aiming for better SQL 96 but if you have to kill ... 95 96
  • 42. 17/09/2019 42 97 ... be gentle :-) 98 Ten Amazing SQL Features Monday, September 16, 02:30 PM - 03:15 PM, Moscone South - Room 203 Proven Ways to Make Applications Slower and Less Secure [THT4796] Tuesday, September 17, 04:30 PM - 04:50 PM, The Exchange - Theater 3 The Best Oracle Database Feature Ever Invented [THT4798] Wednesday, September 18, 10:15 AM - 10:35 AM, The Exchange - Theater 3 Flashback - Not Just for DBAs Wednesday, September 18, 04:00 PM - 04:45 PM, Moscone South - Room 306 PL/SQL: Still the Best Data Access Language Thursday, September 19, 12:15 PM - 01:00 PM, Moscone South - Room 155A 97 98
  • 43. 17/09/2019 43 99 Have a great OpenWorld ! youtube youtube.com/c/ConnorMcDonaldOracle blog connor-mcdonald.com twitter @connor_mc_d 99