How to prevent port timeouts for large remote queries from SQL Server? - sql

I have an unixODBC connection from a linux-based SAP HANA database trying to pull massive amounts of data from another SQL Server 2012 database. Every now and then though I get "Login timeout expired" errors and I also notice via netstat that while the connection reaches "ESTABLISHED" status, it just closes out after about 10 seconds. The issue doesn't happen every time, and I've already done all kinds of due diligence on the network side and found no issues on that end.
Is there anything that can be done on the SQL Server configuration so that the connection doesn't time out?
The current remote query timeout is 600 seconds and remote login time-out is 30 seconds.
I also read in the following link that increasing "Connection timeout" setting in SQL Server helps but how do I change it, it's grayed out.

You are right to note that you need to change the remote query timeout setting to 0.
This link give pretty neat answer to your question. There are ways for doing it via both the SQL Server management Studio, and the command line. However, you need to first login with a user that has the required permissions.

Related

SQL timeouts in ASP.NET after server migration

We have several ASP.NET WebForm sites running on IIS. We switched hosting providers and migrated all of the sites and databases.
After the migration, we are getting timeouts in several places in several sites after 30 seconds. Some are LINQ queries, some are MS Reports, some stored procs.
The code and web.configs were copied directly, so there should be no difference except for the SQL and IIS versions and configurations.
We went from SQL Server 2014 to SQL Server 2019 now running on Windows Server 2019.
IIS server is also on a 2019 server.
In SQL Server, 'Allow remote connections' is checked with a remote query timeout of 600 seconds.
I have added 'Connection Timeout=120' to the connection string in the web.config but it is still timing out after 30 seconds.
Here is an example of one of them coming from a report:
An error has occurred during report processing.
Exception has been thrown by the target of an invocation.
Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
The wait operation timed out
Some of these sites are pretty old and using older methods for connecting to database. I have seen some posts about adding a timeout to the SqlCommand object, but most places we have do not use one. Some code is within a custom data layer and I don't have access to all of the source code to try adding the timeout value.
Any ideas of where this timeout may be coming from?
Any direction would be appreciated.
Any ideas of where this timeout may be coming from?
These are client-side timeouts caused by queries running longer than the SqlCommand.CommandTimeout, which defaults to 30sec.
The recommended upgrade process is to initially leave the databases at their original compatibility level after upgrade to minimize the risk of plan reversion. Then turn on Query Store to gather a performance baseline before increasing the database compatibility level. See
Change the Database Compatibility Level and use the Query Store

The timeout period elapsed prior to completion of the operation or the server is not responding in SQL Server 2008 R2

One of my Windows login is trying to connect to SQL Server 2008 R2 Express; he is facing this issue:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
This Issue appears only once a day i.e. when the initial request is made to connect to the server.
I have tried with my SA login but I didn’t find any issue for the first time login in a day.
He has tried connecting to SQL Server with server name as well as IP address but that hasn’t solved the issue.
Can anyone please resolve this issue?
Thanks in advance.
This thread seems to describe your problem:
http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/58bd9c4d-0572-4567-8e32-82a7fd600022
Yes, i have fixed this problem.
My windows server 2008 was configured to reject SASL LDAP binds (see
warning 2886).
Since i have configured my server to not reject such binds, sql server
2008 connections work correct.
or
I was able to solve the problem of not being able to connect on the
first attempt by configuring the instance of SQL Server to listen on a
static port and adding an exception for that port to the firewall.
You could look here for info.
Less likely, but it's also possible you have Auto_Close enabled.
When set to ON, the database is shut down cleanly and its resources
are freed after the last user exits. The database automatically
reopens when a user tries to use the database again.
When set to OFF, the database remains open after the last user exits.

Lock request timeout Exceeded

I have a dotnet exe app in a server which runs in sql server. during the factory production time my application were unable to connect to db for 1 to 2 minutes and then it gains connectivity at this unresponsive time when i accessed sql server management studio, i got the below error:
Taken from the answer over here.
This usually happens when there are too many open transactions that are blocking read access to your database server. You can try restart your server which will usually solve the issue.

SQL Server does not exist or access denied (intermittently)

I use a Microsoft Access 2010 front end with linked tables on an SQL Server 2012 installation. Local network.
When Access Starts, a VBA script runs which connects to the SQL server and performs some checks.
I recently upgraded from SQL Server 2008 to 2012, that's when the connection between client and Server started to fail intermittently.
When the connection between my client and the server fails, I see a generic message "SQL Server does not exist or access denied". This is covered in a Microsoft support article http://support.microsoft.com/kb/328306. The potential causes detailed in that article do not match the trouble I am encountering.
This connection issue is intermittent. The trouble arises about 3 times a week and lasts for about 30 minutes at a time. Between these 30 minute failures, the the system works perfectly.
My Current VBA Connection String: (have tried several, trouble persists with all of them):
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.Open "Provider=SQLOLEDB;Server=Server3.companydomain.local;Database=My_Database;Trusted_Connection=Yes"
I hope that I can find something in the SQL Server Logs (which I do have access to) but I do not know which Log file to investigate.
I do not have a direct answer to your question, but I believe you could start by exploring the IP and ports on which the SQL server is listening to...Is is possible that the machine using DHCP to assign IP for the DB server as well? In this case I guess it could happen when the IPs are refreshed.
We had a similar issue where multiple IPs were getting assigned on the same machine (having multiple NIC connected) which created such intermittent disruptions.
Well it's been 7 months. Here is the solution for this problem (in my case):
My secondary DNS Server was an external Server. It could not look up my database (192.168.x.x) because this is an internal address.
When My application called the Primary DNS Server to look up the SQL Server address, it worked fine. When my primary DNS was busy, and the application failed over to secondary DNS- the request would time out. There are many reasons someone may see this error. That is the reason I was seeing it.
It's a little strange, but I've found I get this error when I don't have proper "CLOSE DB CONNECTION" type code on my site. And then when too many users hit the site, I start getting this error.
Solution: Do a hard Close of DB connections, after every db call. Yes, most DB Connectors have cleanup routines, but it's not enough under heavy load.
Also, implement a high DB connection limit in the web.config

Sql 2005 Express edition slow connections

I'm running SqlServer 2005 express edition on my laptop for development purposes. It seems that when I open a connection to the database, the setup time is REALLY slow. It can take up to 10 seconds to get a connection. I usually have multiple connections open at the same time (Profiler, Development environment, Query Analyser, etc.) I have a hunch that the slow times are related to the fact that I have multiple connections open.
Is there a governor in Express edition that throttles connection times when multiple connections are made to an instance?
Update:
My workstation is not on active directory, and SQL is running mixed mode security. I will try the login with sql authentication. I am not using user instances.
Update2:
I setup a trace to try and figure out what is going on. When the connection to the database is opened the follow command is executed:
master.dbo.sp_MShasdbaccess
This command takes 6 seconds to execute.
I figured it out. The problem was I had multiple databases with AutoClose set to true. I shut it off in all my databases and the problem went away.
see this article for more info.
Are you sure the connection is the bottleneck? Is it your conn.Open() line that is taking 10 seconds?
AFAIK there's no governer anymore in SQL Express.
Now, are you on a Windows Active Directory Domain? If so, there might be an issue with your DNS or something that means the connection to the domain controller to validate your logon to the server instance is taking the time. I suggest you experiment switching the server over to use SQL Security, give the SA account a password, and try logging in as SA and see if that makes a difference.