oracle's kernel debug, diagnostics & tracing infrastructure file•oracle no longer adds...

13
20.11.18 Page 1 Oracle's kernel debug, diagnostics & tracing infrastructure Stefan Koehler

Upload: lydung

Post on 09-May-2019

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

20.11.18 Page 1

Oracle's kernel debug, diagnostics & tracing infrastructure

Stefan Koehler

Page 2: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

About me

Stefan Koehler• Independent Oracle performance consultant and researcher• 16+ years using Oracle RDBMS - Independent since 2011• Oracle performance and internals geek• Main interests: Cost based optimizer and Oracle RDBMS internals

Services: “All about performance & troubleshooting” • Oracle performance tuning (e.g. Application, CBO, Database, Design, SQL)• Oracle core internals researching (e.g. DTrace, GDB, Perf, etc.)• Troubleshooting nontrivial Oracle RDBMS issues (e.g. Heap dumps, System state

dumps, etc.)• Services are mainly based on short-term contracting

www.soocs.de [email protected] @OracleSK20.11.18 Page 2

Page 3: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

Agenda

• Introduction into Oracle events• Oracle's kernel debug, diagnostics & tracing infrastructure APIs

• Numeric Events (ks*/dbkd*)• Events++ / Generic Debug API (dbgd*)• UTS (Unified Tracing Service) / Generic Trace API (dbgt*)

• How to list and disable set events• Event propagation• Real life use cases

Page 3

Disclaimer: Almost everything is based on research and testing. Test it yourself -with your release and operating system – always! Do not trust anybody! J20.11.18

Page 4: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

Introduction into Oracle events

• Events are built into Oracle‘s low-level kernel debug, diagnostics & tracing infrastructure

• Oracle reengineered its low-level kernel debug, diagnostics & tracing infrastructure with 11g - major kernel components were instrumented with 3 APIs (ks*/dbkd*, dbgd*, dbgt*)

• In general events have 3 different main purposes• Create additional diagnostic data (on specific errors/actions or immediately)• Change Oracle behavior or workaround a specific problem• Enable hidden or undocumented features

• Oracle’s diagnostic and error numbers have the same number range (0 to 65535) and may have an associated default action (e.g. ORA-00600 triggers an errorstack trace)

20.11.18 Page 4

Page 5: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

Oracle's kernel debug, diagnostics & tracing APIs - Numeric Events (ks*/dbkd*)• Event syntax is based on KSD (KSD = Kernel Service Debug)• Oracle no longer adds new numeric trace events - going forward

new trace events use the UTS (Unified Tracing Service)• Some numeric events (e.g. 10046) are mapped (under the

hood) to an Event++ (e.g. sql_trace[])• Some numeric events also have text aliases (e.g. ORA-00060 à

deadlock, ORA-10035 à parse_sql_statement)

20.11.18 Page 5

alter … set events '<EVENT_NUMBER> trace name context forever, level <X>'

When… should actiontake place

Type of action… “trace” is used for tracing, altering behavior and dumps

Name… always used in context with “trace”

Action… context specific trace or “oradebugdumplist”

Options… about duration andcontext specifictrace info

Page 6: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

• Syntax for Events++ is more flexible and powerful• C functions still check for numbers (for details check mapping

file dbgdChkEventIntV_event_list_extended.txt by Hatem)

Oracle's kernel debug, diagnostics & tracing APIs - Events++ (dbgd*)

20.11.18 Page 6

SQL> oradebug doc event…

NAME [<event_name>] List all events or describe <event_name>SCOPE [<scope_name>] List all scopes or describe <scope_name>FILTER [<filter_name>] List all filters or describe <filter_name>ACTION [<action_name>] List all actions or describe <action_name>

SQL> alter … set events 'sql_trace [sql: <sql_id>]';

https://github.com/hatem-mahmoud/scripts/blob/master/dbgdChkEventIntV_event_list_extended.txt

Page 7: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

Oracle's kernel debug, diagnostics & tracing APIs - UTS (dbgt*)• Tracing components can be found in ORADEBUG DOC

COMPONENT• Memory makes tracing info available in circular memory buffer

(X$TRACE) and stack traces (e.g. ORA-00600), if instrumented

20.11.18 Page 7https://github.com/hatem-mahmoud/scripts/blob/master/dbgdChkEventIntV_event_list_extended.txt

SQL> oradebug doc event name tracetrace: Main event to control UTS tracing

Usage-------trace [ component <string>[0] ]disk < default | lowest | low | medium | high | highest | disable >,memory < default | lowest | low | medium | high | highest | disable >,get_time < disable | default | seq | highres | seq_highres >,get_stack < disable | default | force >,operation <string>[32],function <string>[32],file <string>[32],line <ub4>,conuid <ub4>

Page 8: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

How to list and disable set events

• Events can be listed with dbms_system.read_ev() or ORADEBUG but ORADEBUG is more convenient

20.11.18 Page 8

SQL> oradebug doc event action eventdump

eventdump- list events that are set in the group

Usage-------eventdump( group < system | process | session >)

system - Dump system group's event settingsprocess - Dump process group's event settings session - Dump session group's event settings

Page 9: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

Event propagation

• Event information is copied from PGA to SGA (shared pool) when event is set (on system level)

• Event propagation is happening on session creation or next database call by copying event information from SGA to PGA

• Can be controlled via “_evt_system_event_propagation“ (since Oracle 11g)

• Event propagation is broken in Oracle 12.2 (bug #25989066 & #25994378) and fixed in Oracle 18c

20.11.18 Page 9

Page 10: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

Real life use cases (1) - ORA-21780

• Vendor released new PL/SQL application version and customer got an ORA-21780 error after several hours (sometimes days) of running the application

• Vendor was not able to replicate behavior in its own environment for research (even not under high application load)

• What to do next? What is different?

20.11.18 Page 10

shell> oerr ORA 21780

21780, 00000, "Maximum number of object durations exceeded."// *Cause: This typically happens if there is infinite recursion in the // PL/SQL function that is being executed.//// *Action: User should alter the recursion condition in order to // prevent infinite recursion.

Page 11: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

Real life use cases (2) - PARSE but not allowed to FETCH data• https://www.freelists.org/post/oracle-l/Explain-Plan-and-Security

“Explain Plan and SecurityYou might know Kerry’s classic blog: http://kerryosborne.oracle-guy.com/2008/10/explain-plan-lies/

Normally my work around for explain plan issues is to run the query and use dbms_xplan.display_cursor. Now I am working in an environment where I must not run a query, but I can do explain plan. But still I think I can not tolerate explain plan weaknesses.

I am working for a service provider. The data is not ours. We are by policy forbitten to run queries on prod other than against the dictionary.”

20.11.18 Page 11

Page 12: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

www.soocs.de [email protected] @OracleSK

Questions and answers

20.11.18 Page 12

The slides including all demo scripts can be found on my website www.soocs.de/public/talk/

Page 13: Oracle's kernel debug, diagnostics & tracing infrastructure file•Oracle no longer adds new numeric trace events -going forward new trace events use the UTS (Unified Tracing Service)

References• https://oraclue.files.wordpress.com/2011/03/oracle_diagnostic_events_in_11g1.pdf

• https://blog.tanelpoder.com/2009/03/03/the-full-power-of-oracles-diagnostic-events-part-1-syntax-for-ksd-debug-event-handling/

• https://blog.tanelpoder.com/2010/06/23/the-full-power-of-oracles-diagnostic-events-part-2-oradebug-doc-and-11g-improvements/

• https://mahmoudhatem.wordpress.com/2018/10/12/oracle-trace-events-hunting-dbgdchkeventintv/

• https://mahmoudhatem.wordpress.com/2018/10/18/oracle-trace-events-hunting-undocumented-events-filling-the-gaps/

• https://mahmoudhatem.wordpress.com/2018/10/25/oracle-trace-events-hunting-kst-tracing-xtrace/

• https://nenadnoveljic.com/blog/event-propagation-in-oracle-12-2/

• https://www.youtube.com/watch?v=mkmvZv58W6w

• https://www.slideshare.net/tanelp/oracle-xtrace-exotic-wait-event-types-and-background-process-communication

20.11.18 Page 13