Presentation is loading. Please wait.

Presentation is loading. Please wait.

Troubleshooting applications accessing SQL Server

Similar presentations


Presentation on theme: "Troubleshooting applications accessing SQL Server"— Presentation transcript:

1 Troubleshooting applications accessing SQL Server
Abirami Iyer (Sr. Support Escalation Engineer) Lakshmi Jonnakuti (Escalation Engineer)

2 Kerberos is not part of our Agenda
Review of common connectivity errors Troubleshooting Checklist Demo-1:Troubleshooting Connection Timeout Demo-2 : Troubleshooting Connection Leak Programming Best Practices

3 Connectivity methods for accessing SQL Server
SQL Client SQL Native Client ODBC & OLEDB OLEDB ODBC ADO.Net Object MDAC/WDAC New in SQL 2005 SQLOLEDB SQL SERVER DRIVER SNI(SQL Server Network Interface) DBNETLIB Replaces Net-Libraries for SQL 2000 SQL SERVER Driver for PHP JDBC

4 Isolating the problem

5 Common Connectivity Errors
An error has occurred when establishing a connection to server - when connecting to SQL Server 2005 this failure may be caused by the fact that under default setting does not allow remote connections Provider: Named pipes provider, error: 40 could not open a connection to SQL Server Provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified 1. Application tried to use TCP and it failed. It then tried Named Pipes and it failed too. Server is not listening on named pipes is the frequent cause. It can be due to access denied on the pipe. 2. Error 26- Error Locating Server/Instance specified is likely due to SQL Browser not started (for named instances) or port 1434 not open on the firewall. 3. This error is likely due to the fact that the TCP port on which SQL Server is listening is blocked by the firewall. 4. The protocol requested by the client to connect to server is not enabled on the server side. Provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it. SQL Network Interfaces: Server doesn't support requested protocol [xFFFFFFFF].

6 Common Connectivity Errors
GNE Common Connectivity Errors [Microsoft][ODBC SQL Server Driver][DBNETLIB] General Network error. Check your network documentation. A transport-level error has occurred when sending the request to the server. (Provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.) [Microsoft][SQL Native Client]Communication link failure 1. The first three errors are different flavors of General Network Errors. They mean that an already established connection had an error likely due to network issues which may be resets, retransmits, delays in network etc. 2. SQL Server does not exist or access denied is a special case of error where the client was not able to establish the connection either because the requested server does not exist or client does not have permissions to open the client port(ephemeral port). [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

7 Common Connectivity Errors (Timeout)
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.(Provider: TCP Provider, errror:0-A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) Client makes a connection and typically waits for a duration for the server to respond and establish a connection. If there is no response received in that duration, client throws timeout error and disconnects the connection. This error is specific to SQL Client since the connection pool has a max size of 100 (which is configurable).This error is due to the fact the connections are not being closed properly and hence the max size has been reached. 3. Same as the first error but from a different provider (SQL Native Client).

8 Isolating the problem Has this worked in the past?
Anything changed? (code, network topology) Isolating the problem Has this worked in the past? SQLClient, SNAC, OLEDB, ODBC What provider are you using? Try using UDL Is the problem reproducible outside the app? TCP/IP, NP Connect using different protocols OS, Router, Domain Only few clients affected? Likely a configuration issue Is the problem consistent? Auto Recover\Restart If something changed recently, review changes like code, network topology etc. Try a simple application with another driver. Knowing the provider also helps to choose appropriate tracing mechanism. Check if the problem is reproducible outside the application. Simple test can be done by using UDL which ships with MDAC. If TCP fails, this can be a Kerberos issue or TCP port blocking etc. If NP fails, this can be due to Incorrect Pipe name or port 445 can be blocked etc. If it is just few clients, are these clients part of the same subnet or router or domain or OS? Do they have anything in common? If the problem is consistent it is likely a configuration problem. Do you restart the application or does it auto-recover? If it auto-recovers, there might be a network glitch that you might want to check. Pinging will verify basic network functionality. If ICMP packets are blocked, ping may not work but it does not translate to a network issue. You may also just try mapping drivers to verify any potential permission issues. Look for clues in application logs, SQL Server error logs, event logs around the same time of the problem. How do you recover? Basic Network Functionality, mapping drives Can you ping SQL Server? Other relevant errors\warnings? Errors in Event logs, SQL Server error logs?

9 Client Side Checklist Connection String Parameters DSN
ServerName, Port Number, Connection Timeout Values Client Side Checklist Application Configuration Connection String Parameters SQL Server Configuration Manager Enabled protocols PipeName Port number Aliases ODBC Administrator DSN Last Connect Cache [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SNI9.0\LastConnect] 1. Check the server name, port number, connection timeout values in the connection string. 2. Using SQL Server Configuration Manager, check the protocols, pipe name, port number and aliases configured to make sure they are set properly. 3. Using ODBC Administrator, check if the DSN that your application uses is configured properly. 4. LastConnect key maintains the information about the last successful connection for each server. As part of troubleshooting, try deleting this key and see if your connection succeeds. Saves the last successful connection details for each server

10 Server Side Checklist Startup Mode Not in single user mode and undocumented trace flags Surface Area Configuration Local and remote connections SQL Server Configuration Manager Enabled Protocols Pipe Name Port Number SQL Browser Error Log Errors and warnings Trace Flag 4029, 3689 Applies only to SQL 2005 SQL Browser is needed to connect to Named Instances Verify that the SQL Server is not started in single user mode. This error message is usually logged in the SQL error log. Also, please make sure that SQL Server is not started using some undocumented trace flags. For SQL 2005, verify if remote connections are enabled using Surface Area Configuration. In SQL Server Configuration Manager, check the server side properties to make sure the protocols, pipe name, port number are set properly. SQL Browser must be started for the clients to connect to Named Instances. Check the SQL Server error log for any errors and warnings. Trace flags 4029 and 3689 are used to log errors on network reads and writes which is helpful to troubleshoot connectivity issues.

11 Use Static port for Named Instances if you are using Firewall
Network Checklist Firewall Rules TCP Port 1433 for default instance UDP Port 1434 for SQL Browser TCP Port 1434 for DAC TCP Port 445 for Named Pipes Name Resolution DNS/WINS/Hosts/Lmhosts SNP Detour Software Third party detour software that alter the behavior of SQL Server are not supported NIC Teaming IPSEC IPSec Rules Ping –a, NSLookup In your firewall rules, check the listed ports are open. Named instances use dynamic ports and hence if you are using firewall, it is advised to use static ports so that you can configure the rules for that port. Check if you can resolve SQL Server name fully using either ping or NSLookup. Scalable Network Pack allows admins to optimize the network performance. If this feature is enabled and you have a network drive that is not compatible with this feature, you may see connectivity problems. In that case, try testing by disabling this feature and if connection succeeds, you may want to get in touch with your vendor to upgrade the driver. Third party detour software that can alter the behavior of SQL Server is not supported. When you call CSS, we disable this feature for troubleshooting. Refer KB: for more information. NIC Teaming – Grouping few physical NIC cards into one logical NIC which is used for fault tolerance and load balancing. This can cause connectivity failures. In CSS, we recommend breaking NIC Teaming to troubleshoot further. KB has more details. IPSEC secures your IP communication by authenticating or encrypting each IP packet of a data stream. If the IPSEC rules are improperly configured, they can block connections.

12 Troubleshooting Demo 1 Troubleshooting Connection Timeout
BID Trace & Network Monitor Trace

13 Troubleshooting Connection Leak
Troubleshooting Demo 2 Troubleshooting Connection Leak DebugDiag & WinDbg

14 Programming Best Practices
Opening Connections Open Connections as late as possible Closing Connections Close connections explicitly as soon as possible Don’t close connections in Finalize method Sharing Connections Be Cautious about sharing connections in multithreaded applications Open connections as late as possible. Close them explicitly as soon as possible. Connection Pooling algorithm is robust enough to manage resources. Closing connections in finalize method increases the lifetime of the connection and delays garbage collection. Finalize method is intended to dispose unmanaged resources only. In multi- threaded applications, sharing connections can lead to data corruption if connections are not synchronized properly. Please make sure that you are not using static connections or global connections which can raise issues in multi-threaded applications. You can troubleshoot this problem by scoping down a connection using the USING keyword and if the problem goes away, it indicates that you are sharing connections. Applies to any managed object

15 Resources Configuring the Windows Firewall to Allow SQL Server Access
An update to turn off default SNP features is available for Windows Server 2003-based and Small Business Server 2003-based computers Best Practices for Using ADO.NET The use of third-party detours or similar techniques is not supported in SQL Server Debug Diagnostics Whitepaper How to capture network traffic with Network Monitor ETW Tracing SQL Server Driver for PHP Network adapter teaming and server clustering

16 Tools Tracing Data Access (BID Trace)
How to capture network traffic with Network Monitor Debug Diagnostics Tool Debugging Tools for Windows (including Windbg) Log Parser

17 Pre-Conference Seminar
Microsoft CSS at PASS 2009 Pre-Conference Seminar Tackling Top Reporting Services Issues Mon 11/2 8:30am-4:30pm Adam Saxton Main Conference Talks (DBA-500-SC) Inside SQL Server Wait Types Tues 11/3 10:15 – 11:45am 3AB Bob Ward (DBA-X69-C) Implementing and Supporting SQL 2008 Failover Clustering Tues 11/3 1:30-2:45pm 4C1-2 Shon Hauck (BIA-X45-C) Top customer support issues in Analysis Services Wed 11/4 1:30-2:45pm 2AB John Sirmon (AD-X43-C ) Troubleshooting applications accessing SQL Server Thurs 11/5 1:00-2:15pm Abirami Iyer and Lakshmi Jonnakuti SQL Server Clinic Room 611 11/3 – 11/5/2009 After Keynote – 6:00pm…ish

18 Complete the Evaluation Form & Win!
You could win a Dell Mini Netbook – every day – just for handing in your completed form! Each session form is another chance to win! Pick up your Evaluation Form: Within each presentation room At the PASS Booth near registration area Drop off your completed Form: Near the exit of each presentation room Sponsored by Dell

19 for attending this session and the 2009 PASS Summit in Seattle
Thank you for attending this session and the PASS Summit in Seattle

20 Microsoft Technical Learning Center Located in the Expo Hall
Visit the Microsoft Technical Learning Center Located in the Expo Hall Microsoft Ask the Experts Lounge Microsoft Chalk Talk Theater Presentations Microsoft Partner Village


Download ppt "Troubleshooting applications accessing SQL Server"

Similar presentations


Ads by Google