Troubleshooting Ninja using PowerBI and SQL Server Extended Events

Slides:



Advertisements
Similar presentations
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Connect with life Praveen Srvatsa Director | AsthraSoft Consulting Microsoft Regional Director, Bangalore Microsoft MVP, ASP.NET.
 Alexander Malek Lead Program Manager SharePoint Microsoft Corporation BB47.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
A Windows Azure application runs multiple instances of each role A Windows Azure application behaves correctly when.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Amit Bansal CTO | Peopleware India (unit of eDominer Systems) | |
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

Speaker Name 00/00/2013. Solution Requirements.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Connect with life Vinod Kumar Technology Evangelist - Microsoft
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Sr. Dir. – Systems Architecture Inlet Technologies.
Praveen Srivatsa Director| AstrhaSoft Consulting blogs.asthrasoft.com/praveens |

SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS.
MIX 09 4/17/2018 4:41 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
System Center Marketing
System Center Marketing
Troubleshooting Ninja using PowerBI and SQL Server Extended Events
7/2/2018 2:39 AM BRK2413 Customer lifecycle with LCS: Dynamics 365 for Finance and Operations, Enterprise edition Manali Dongre Senior Program Manager.
Optimizing Microsoft OneDrive for the enterprise
Amit Banerjee Sr. Program Manager Microsoft Database Systems
Managing the Solution Lifecycle for xRM Applications
7/28/ :17 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or.
SQL Server Debugging Made Easy using Extended Events
Mission-critical performance with Microsoft SQL Server 2016
SQL Server Integration Services
Introduction to SQL Server Management for the Non-DBA
Required 9s and data protection: introduction to sql server 2012 alwayson, new high availability solution Santosh Balasubramanian Senior Program Manager.
Test Upgrade Name Title Company 9/18/2018 Microsoft SharePoint
Dimodelo Solutions.
Microsoft Build /8/2018 5:15 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Your Data Any Place, Any Time
Microsoft Virtual Academy
Troubleshooting Availability Group Failovers
Azure SQL Database: A Guided Tour
What’s new in SQL Server 2016 Availability Groups
TechEd /24/2018 8:21 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered.
SQL Server 2016 Query Data Store
11/29/2018 1:22 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Office Mac /30/2018 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Turbo-Charged Transaction Logs
Title of Presentation 12/2/2018 3:48 PM
Intro to Workflow Services and Windows Server AppFabric
System Admin Best Practices for NAV 2013 R2
28 days.
Virtual Reality with Azure and Unity
Using Power Bi to troubleshoot SQL Server instances
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
When Bad Things Happen to Good Applications
Andrew Fryer Microsoft UK
Windows 8 Security Internals
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
DevOps better together with System Center 2012 SP1 and Visual Studio
Шитманов Дархан Қаражанұлы Тарих пәнінің
Diagnostics and troubleshooting in Azure App Service Support Center
Title of Presentation 5/24/2019 1:26 PM
日本初公開!? Vista の新機能を実演 とっちゃん わんくま同盟 7/23/2019 9:09 AM
7/28/ :33 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or.
Microsoft Virtual Academy
Presentation transcript:

Troubleshooting Ninja using PowerBI and SQL Server Extended Events Ajay Jagannathan (@ajaymsft) Principal Program Manager - Microsoft SQL Saturday #582, Melbourne 11th February 2017

Housekeeping Mobile Phones Evaluations Please set to “stun” during sessions Evaluations Please complete a session Evaluation to provide feedback to our wonderful speakers! Also complete the Event Evaluation forms – please fill them in and return them at the end of the day

Session Objectives And Takeaways Tech Ready 15 11/13/2018 Session Objectives And Takeaways Understand capabilities of Extended Events to troubleshoot and mitigate issues quickly in mission-critical environments Set up session templates proactively to reduce mitigation time during reactive situations Use Extended Events to troubleshoot and resolve complex issues in a timely manner © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Best Practices Premise: “drop events, not performance” Event Buffers Avoid EVENT_RETENTION_MODE = NO_EVENT_LOSS Best Practices Event Buffers None: 3 buffers (fixed) x 1.3 MB ~4.0 MB (Default MAX_MEMORY=4.0 MB) Node: 3 * number_of_nodes CPU: 2.5 * number_of_cpus For high end machines MEMORY_PARTITION_MODE=PER_NODE | PER_CPU Increase MAX_MEMORY, use multiple XE file targets to increase write throughput Example: 4 node, 16 logical cores/node Avoid expensive Events e.g. showplan Actions e.g. callstack Filters on text columns Event session options http://blogs.msdn.com/b/extended_events/archive/2010/03/31/option-trading-getting-the-most-out-of-the-event-session- options.aspx Memory partitioning http://blogs.msdn.com/b/extended_events/archive/2010/12/07/session-memory-who-s-this-guy-named-max-and-what-s-he- doing-with-my-memory.aspx Buffer memory http://blogs.msdn.com/b/extended_events/archive/2010/06/28/take-it-to-the-max-and-beyond.aspx

Configure Extended Events Session

Common Scenarios

System Health Session Default session and is always running Targets – ring buffer and persisted XEL Files – 4 files of 5MB each scheduler_monitor_deadlock_ring_buffer_recorded scheduler_monitor_non_yielding_iocp_ring_buffer_recorded scheduler_monitor_non_yielding_ring_buffer_recorded scheduler_monitor_non_yielding_rm_ring_buffer_recorded scheduler_monitor_stalled_dispatcher_ring_buffer_recorded scheduler_monitor_system_health_ring_buffer_recorded Events for scheduler, memory, waits, critical errors, deadlocks Scheduler memory_broker_ring_buffer_recorded memory_node_oom_ring_buffer_recorded clr_allocation_failure clr_virtual_alloc_failure Memory sp_server_diagnostics results included for Standalone, FCI or AlwaysOn instances SYSTEM, RESOURCE, QUERY, IO connectivity_ring_buffer_recorded security_error_ring_buffer_recorded error_reported process_killed sql_exit_invoked Errors wait_info (Latches and Locks) wait_info_external (External OS Waits) xml_deadlock_report Waits

Insights into System Health

Visualize using Power BI Query Performance What are the slowest queries? Which queries are driving my CPU? Who is driving the IO on this system? How do I know if query plans changed? Collect Extended Events Export to table Visualize using Power BI

Query Performance Insights using Power BI

Backup and Restore tracing 11/13/2018 1:12 AM Backup and Restore tracing Long running tasks Not enough insight into progress Trace flag (3004) output is cryptic and unformatted Errorlog TF 3014 = TF 3014 + TF 3004 + TF 3212 (buffer config details) Formatted messages - Backup(dbname) and Restore(dbname) All errors (currently sent to the client, which can be lost) Extended Event backup_restore_progress_trace SQL Server 2016 Options - checksum, compression, encryption, and buffer configs Size estimation before starting actual copy operation Elapsed time - checkpointing, zeroing files (restore), history table updates Percentage progress during file processing Waits for locks - only high-level/database-level locks Major steps for filestream filegroups First/last LSNs in consistent format Backup and restore are long running tasks in SQL Server with limited insights into progress. Often a question asked is “How much longer will it take for this operation to complete?”. Though there are trace flags and DMVs that provide some information, they are either unstructured (ex: trace flags send output to error logs and can be hard to parse) or hard to interpret. In SQL Server 2016 (starting with CTP 2), we have introduced a new extended event that can be used to easily gain insight into progress of any of these long running activities. In addition, you can leverage the rich collection and diagnostic capabilities of extended events for advanced analysis. We hope that this extended event will simply your troubleshooting experience with backup and restore activities. Single Extended Event You can turn on the backup_restore_progress_trace extended event to trace both Backup and Restore progress. CREATE EVENT SESSION [Backup trace] ON SERVER ADD EVENT sqlserver.backup_restore_progress_trace ADD TARGET package0.event_file(SET filename=N’Backup trace’) WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS, MAX_DISPATCH_LATENCY=5 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE, TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) GO The event has the following data that is part of the payload. name type_name description operation_type database_operation_type Type of operation – Indicates whether the database is being backed up or restored trace_level backup_restore_trace_level Backup/Restore trace level database_name unicode_string Logical name of the database trace_message unicode_string Progress trace messages for key steps in backup or restore   name map_key map_value database_operation_type 0 Backup database_operation_type 1 Restore backup_restore_trace_level 0 Information of major steps in the operation backup_restore_trace_level 1 Verbose I/O related information Sample Output from a backup process with key information and phases highlighted: Sample Output from a restore process with key information and phases highlighted: © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Database Recovery tracing 11/13/2018 1:12 AM Database Recovery tracing Limited information available during database recovery activities such as Analysis, Redo and Undo Errorlog Does not output during Analysis phase “Recovery of database ‘%’ is xx% complete (approximately yy seconds remaining) Three new Extended Events: database_recovery_progress_report database_recovery_times database_recovery_trace SQL Server 2016 As most of you can attest, there is limited information available during database recovery activities such as Analysis, Redo and Undo phases. I am happy to share that in SQL Server 2016, we have introduced three new extended events to help you gain insight into database recovery. database_recovery_progress_report This event can be used to gather high level progress information such as phase, percent_complete and estimated time during database recovery. The following data is available as part of the event: name phase percent_complete total_elapsed_time_sec estimated_remaining_time_sec database_name   Recovery phase in the extended event payload can be one of the following: PreRecovery Analysis Redo Undo Complete PostRecovery database_recovery_times With this extended event, you can also get the recovery time for specific steps during database startup.   database_recovery_trace If the two extended events listed above are not sufficient and you wanted detailed insight, you can also turn on database_recovery_trace extended event. Note that this can generate lot of data and use with caution. Off course, you can leverage the filtering capabilities of the extended event framework to limit the collection to a specific database or a specific phase. Some of the useful information that you can instantly get are: Number of VLFs Estimated log size Number of transactions Time spent in each phase © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Database Recovery progress 11/13/2018 1:12 AM Database Recovery progress Progress and time estimates for various phases Recovery time for specific steps during database startup SQL Server 2016 Extended Event Session Script The following session definition was used to collect the events above. Though the session can be launched any time during the middle of a long running recovery to gather insight, you can turn on the startup state for the session to automatically launch at startup in case you want to collect data during server startup when database recovery usually happens.   CREATE EVENT SESSION [recovery_trace] ON SERVER ADD EVENT sqlserver.database_recovery_progress_report(SET collect_database_name=(1)), ADD EVENT sqlserver.database_recovery_times, ADD EVENT sqlserver.database_recovery_trace ADD TARGET package0.event_file(SET filename=N’recovery_trace’) WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=3 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON) GO © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Backup, Restore and Recovery

AG Failover Logs to be collected SQL Server Errorlog from the time of the failure Windows Application and System Event logs from the time of the failure All the Failover Cluster Instance Diagnostics log (upto a maximum of 10 rollover .xel files by default) All the AlwaysOn Extended Event session log files (upto a maximum of 4 rollover .xel files by default) System Health Session Extended Event session files (optional as the component health state information is present in #4) Windows Cluster log

AG Failover

Bookmarks SQL Server Tiger Team Blog Tiger Toolbox GitHub SQL Server Release Blog BP Check SQL Server Standards Support Trace Flags SQL Server Support lifecycle SQL Server Updates Twitter http://aka.ms/sqlserverteam http://aka.ms/tigertoolbox http://aka.ms/sqlreleases http://aka.ms/bpcheck http://aka.ms/sqlstandards http://aka.ms/traceflags http://aka.ms/sqllifecycle http://aka.ms/sqlupdates @mssqltiger

Powershell Extensions 11/13/2018 1:12 AM Powershell Extensions PS SQLSERVER:\XEvent\TR23DEMO\SQL2016\Sessions\system_health> dir Events Name Package Name Predicate Description ---- ------------ --------- ----------- sqlclr.clr_allocation_failure sqlclr A memory allocation failed. sqlclr.clr_virtual_alloc_fa... sqlclr A virtual memory allocation failed sqlos.memory_broker_ring_bu... sqlos Memory broker ring buffer recorded sqlos.memory_node_oom_ring_... sqlos Memory node OOM ring buffer recorded sqlos.process_killed sqlos Process killed sqlos.scheduler_monitor_dea... sqlos Deadlock ring buffer recorded for sch... sqlos.scheduler_monitor_non... sqlos Nonyielding IOCP ring buffer recorded... sqlos.scheduler_monitor_non... sqlos Nonyielding ring buffer recorded for ... sqlos.scheduler_monitor_non... sqlos Non-yielding resource manager ring bu... sqlos.scheduler_monitor_sta... sqlos Stalled dispatcher event recorded for... sqlos.scheduler_monitor_sys... sqlos System health ring buffer recorded fo... sqlos.wait_info sqlos ([duration]>(1500... Occurs when there is a wait on a SQLO... sqlos.wait_info_external sqlos ([duration]>(5000... Occurs when a SQLOS task switches to ... sqlserver.connectivity_ring... sqlserver Occurs when there is a server-initiat... sqlserver.error_reported sqlserver ([severity]>=(20)... Occurs when an error is reported. sqlserver.security_error_ri... sqlserver Security error ring buffer recorded sqlserver.sp_server_diagnos... sqlserver ([sqlserver].[is_... Occurs when a component state is dete... sqlserver.sql_exit_invoked sqlserver Occurs when SQLExit() routine is invoked sqlserver.xml_deadlock_report sqlserver Produces a deadlock report in XML for... https://msdn.microsoft.com/en-us/library/ff877887(v=sql.130).aspx © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Somebody got hurt real bad!!!  Lease Timeout Somebody got hurt real bad!!! 

Availability Group: Lease Timeout 11/13/2018 1:12 AM Availability Group: Lease Timeout hadr_ag_lease_renewal - Renews every 5 seconds availability_group_lease_expired – Raised when the lease expires Root Cause Analysis SQL Server 2012 Service Pack 3 and above DBA INVESTIGATION: WILL TAKE TIME Production Server More information about this improvement can be found in the following articles: https://blogs.msdn.microsoft.com/alwaysonpro/2016/02/23/improved-alwayson-availability-group-lease-timeout-diagnostics/ https://support.microsoft.com/en-us/kb/3112363 Refer the following for Lease Timeouts: https://blogs.msdn.microsoft.com/psssql/2012/09/07/how-it-works-sql-server-alwayson-lease-timeout/ © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES EXPRESS IMPLIED OR STATUTORY AS TO THE INFORMATION IN THIS PRESENTATION.

Availability Group: Latency 11/13/2018 1:12 AM Availability Group: Latency SQL Server 2012 Service Pack 3 and above Root Cause Analysis DBA INVESTIGATION: WILL TAKE TIME Production Server hadr_apply_log_block hadr_send_harden_lsn_message hadr_capture_log_block hadr_transport_flow_control_action hadr_capture_vlfheader hadr_database_flow_control_action hadr_transport_receive_log_block_message log_block_pushed_to_logpool hadr_db_commit_mgr_harden log_flush_complete hadr_log_block_compression log_flush_start hadr_log_block_decompression recovery_unit_harden_log_timestamps hadr_log_block_group_commit hadr_log_block_send_complete hadr_lsn_send_complete hadr_receive_harden_lsn_message © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES EXPRESS IMPLIED OR STATUTORY AS TO THE INFORMATION IN THIS PRESENTATION.

Questions? Please make sure you visit our fantastic sponsors to get your card stamped to be in the running for a raffle prize:

How did we do? Please complete an Evaluation to provide feedback to our wonderful speakers! SQL Clinic Don’t forget to check out the SQL Clinic to talk directly to Microsoft staff and MVP’s about your biggest pain points or suggestions for the next versions of SQL Server Lunchtime Sponsor Sessions Learn more over lunch, come hear presentations from our gold sponsors including WardyIT, SanDisk, RockSolid and Insight Enterprises Evaluations Also complete the Event Evaluation forms – please fill them in and return them at the end of the day

11/13/2018 1:12 AM © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.