The document discusses enhancements to Extended Events in SQL Server 2012. It provides an overview of Extended Events, terminology used in Extended Events, and highlights key enhancements in SQL Server 2012 such as an improved user interface, expanded system coverage, and a managed code API.
2. Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
3. Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
4. About 888
• 888.com is a global online gaming company.
• Our purpose is to provide quality
entertainment for people who enjoy
gambling.
• Giving them the opportunity to do so in a safe,
fun, fair, regulated and secure environment.
5.
6. 888 Database Environment
50 Production Instances
300 Development Instances
400 Databases
250 TB Of Data
24*7 Availability
99.95 Uptime
7. Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
8. Extended Events
• General event-handling system for windows
servers
• Used for problem diagnosis and info gathering
and auditing
• The Extended Events infrastructure supports
the correlation of data from SQL Server and
OS
9. Extended Events
• Support 7 different types of targets
• Event and consumer agnostic
– Any event can be processed by any consumer
– New events can be added, immediately useable
• Rich predicate system for filtering
• Less overhead than server-side trace queues
– 10,000 events processed will consume 1% of
single 2GHz processor
10. Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
12. Extended Events 2008
drawbacks
• XE required extensive understanding of
system catalog views and DMVs
• Event Sessions could only be managed
through the use of DDL commands
• Reading target data requires the use of
XQuery
13. Extended Event Metadata
• Catalog views for defined session info
– server_event_sessions
– server_event_session_target
– server_event_session_fields
– server_event_session_actions
– server_event_session_events
• DMVs for Event System Metadata
– dm_xe_package
– dm_xe_objects
– dm_xe_object_columns
– dm_xe_map_values
• DMVs for currently active session info
– dm_xe_sessions
– dm_xe_session_targets
– dm_xe_events
– dm_xe_event_actions
– dm_xe_object_columns
14. Demo
Capture errors with XE 2008
• Find events and actions
• Create a new event session
• View the output
15. Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
17. Packages
• Packages are metadata containers
• Packages register at module load time
• 9 available packages
• package0 - XE system objects (default)
• sqlserver - SQL Server related objects
• sqlos - SQL Server Operating System (SQLOS) related
objects
• SQL audit uses private XE package
18. Events
• An event is a well known point in code
• Unique schema for each event
• Supports optional fields
• Events fire synchronously
• 264 events in 2008 R2
• 618 events in 2012
19. Actions
• programmatic response or series of responses
to an event
• Can be added to any event
• Adds data to the event payload
• Actions are invoked synchronously
• Trigger a memory dump
21. Targets
• Target is an event consumer
– Can be synchronous or asynchronous
• Target types
– event_file
– event_counter
– histogram
– etw_classic_sync_target
– pair_matching
– ring_buffer
– event_stream
22. Demo
Monitor locks
Present different types of targets
• Ring buffer
• Event file
• Event counter
• Histogram
• Pair Matching
• Etw_classic_sync_target
23. Predicates
• Predicates are a set of logical rules that are
used to evaluate events when they are
processed.
• Boolean expressions using flexible operators
• Event data
• Action data
• Global State
25. Event Session
• The materialization of combination of metadata
elements of XE architecture
• Multiple targets per session
• Event can be in many sessions
– Actions/Predicates are per event
• Event Session can specify what to do if target can't
keep up
• Event Session defines data retention
• Event session can add or remove events on runtime
27. Event life cycle
Pre-Collect Collection Predicate evaluation
Customizable attribute check
IsEnabled check Predicate evaluation
Event data collected
Publish
Actions executed Synchronous targets served Event data buffered for asynchronous targets
28. Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
29. Extended Events 2012
Enhancements
• User Interface
– Advanced & Wizard UI for creating and managing
– Display & Analysis
• Expanded to other systems
– Analysis Services, Replication, PDW
• Managed code
– Powershell object model for runtime and meta
data
– Reader API for XEL files and near real time stream
30. User Interface
• Event Session list
– Provides a list of Event Sessions
• New Session Wizard
– Provides a simplified experience for creating an
Event Session
• Extended Events display
– Tabbed windows that display Extended Events
trace data
32. Extended Events Management
API
• Management API provides the ability to create
and modify event sessions
• Provides a complete object model for XE
usage by managed applications
• Provides a XEReader API for reading event files
and event streams coming from a running
event session on a server
33. Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
34. Extended Event Use Cases
• Proactive monitoring
– Application errors
– Errors log
– Event grouping
• Troubleshooting
– Page Split
– blocking
• Audit
– Monitor the access of privileged and non privileged
users
36. Summary
• SQL Server 2012 offers simplified diagnostic
tracing with Extended Events
– Management Studio integration provides SQL
Server Profiler functionality for Extended Events
allowing Event Sessions to be created, modified,
and scripted
– Management API allows managed applications to
be developed that leverage Extended Events
Hinweis der Redaktion
Event: sql_statement_completedActions:plan_handle, query_hash, session_id, sql_textTargets: histogram on query_hash, event fileIn target display – choose columns: cpu_time, duration, logical_reads, query_hashGroup by query_hashFrom XE menu – aggregate by cpu_time and durationSave to table
http://www.sqlserver.co.il/?p=1574
Demo – extended event 2008 . Create session that record log wait.Start session Read result Stop session -- system catalog?
Catching errors with profiler: errors and warnings -> user error message -> column filters -> severity >= 16Can’t see the actual query that caused the errorXE allows us to add additional fields like sql_text, using an uncomfortable UI to create the capture and then script to parse the xml data
Module – exe or dllPackage - a container for XE objects
package0 - XE system objects (default)sqlserver - SQL Server related objectssqlos - SQL Server Operating System (SQLOS) related objects
monitoring points of interest the code
Actions are:programmatic response or series of responses to an eventActions are invoked synchronously on the thread that fired the eventActions can:Capture a stack dump and inspect data.Store state information in a local context using variable storage.Aggregate event data.Append data to event data.Examples of actions:Stack dumperExecution plan detection (SQL Server only)Transact-SQL stack collection (SQL Server only)Run time statistics calculationGather user input on exception
Events: lock_acquired, lock_releasedActions: client_app_name, database_name, session_id, sql_textTargets:Ring buffer – store data in the memory, cyclic. Watch live data view target (xml)Parse ring buffer XMLEvent file –data is saved in a file, can be archived and reviewed at different timesView targetEvent counter – Counts the number of eventsHistogram – aggregate data on specific event data field or actionFilter on lock_acquiredBase buckets on field mode (type of lock)Pair Matching – pair two related events and output only events that are not matchedBegin with: lock_acquired, end with: lock_releasedActions: session_id, resource_0, resource_1, resource_2Etw_classic_sync_targetLocks types: 0=NULL - Compatible with all other lock modes (LCK_M_NL)1=Schema Stability lock (LCK_M_SCH_S)2=Schema Modification Lock (LCK_M_SCH_M)3=Shared Lock (LCK_M_S)4=Update Lock (LCK_M_U)5=Exclusive Lock (LCK_M_X)6=Intent Shared Lock (LCK_M_IS)7=Intent Update Lock (LCK_M_IU)8=Intent Exclusive Lock (LCK_M_IX)9=Shared with intent to Update (LCK_M_SIU)10=Shared with Intent Exclusive (LCK_M_SIX)11=Update with Intent Exclusive (LCK_M_UIX)12=Bulk Update Lock (LCK_M_BU)13=Key range Shared/Shared (LCK_M_RS_S)14=Key range Shared/Update (LCK_M_RS_U)15=Key Range Insert NULL (LCK_M_RI_NL)16=Key Range Insert Shared (LCK_M_RI_S)17=Key Range Insert Update (LCK_M_RI_U)18=Key Range Insert Exclusive (LCK_M_RI_X)19=Key Range Exclusive Shared (LCK_M_RX_S)20=Key Range Exclusive Update (LCK_M_RX_U)21=Key Range Exclusive Exclusive (LCK_M_RX_X)
This enables the Extended Events user to selectively capture event data based on specific criteria.New operator – modulus, gt mod, lt mod….
Fix template…?
The mapping between package objects and sessions is many to many, which means that that an object can appear in several sessions, and a session can contain several objects.
The materialization of combination of metadata elements of XE architecture
Not sure is needed
UI for creation and management
Event: sql_statement_completedActions:plan_handle, query_hash, session_id, sql_textTargets: histogram on query_hash, event fileIn target display – choose columns: cpu_time, duration, logical_reads, query_hashGroup by query_hashFrom XE menu – aggregate by cpu_time and durationSave to table
dbo.trace_xe_event_maphttp://blogs.msdn.com/b/extended_events/archive/2010/12/10/migrating-from-sql-trace-to-extended-events.aspxUSE MASTER; GO USE MASTER; GO SELECT DISTINCT tb.trace_event_id, te.name AS 'Event Class', em.package_name AS 'Package', em.xe_event_name AS 'XEvent Name', tb.trace_column_id, tc.name AS 'SQL Trace Column', am.xe_action_name as 'Extended Events action' FROM (sys.trace_eventsteLEFT OUTER JOIN sys.trace_xe_event_mapem ON te.trace_event_id = em.trace_event_id) LEFT OUTER JOIN sys.trace_event_bindingstb ON em.trace_event_id = tb.trace_event_idLEFT OUTER JOIN sys.trace_columnstc ON tb.trace_column_id = tc.trace_column_idLEFT OUTER JOIN sys.trace_xe_action_map am ON tc.trace_column_id = am.trace_column_id ORDER BY te.name, tc.name