How to fix hikariPool connection timeout with sql-server? - sql-server

I have a Java/Spring app that uses JDBC and HikariCP with a SQL Server instance,
I found this warning to occur too frequently in the logs:
HikariPool-2 - Failed to validate connection ConnectionID:2483
ClientConnectionId: c8a86a9c-b804-4060-a118-01378e040b59 (The
connection is closed.). Possibly consider using a shorter maxLifetime
value."
To solve this I tried to configure the data source as this:
jdbc-url: "jdbc:sqlserver://my-db.dev.aws-some-db.com;databaseName=MYHUGEDB"
username: "someUsername"
password: "somePassword"
maximumPoolSize: "10"
maxLifetime: "60000"
keepaliveTime: "40000"
I choose the maxLifeTime to be less then the SQL Server query time out,
To find the SQL Server time, I executed this SQL query:
EXEC SP_CONFIGURE 'remote query timeout'
It returns:
config_value: 600 (s)
run_value: 600 (s)
Normally 600s > 60000(ms), so it should not raise this warn, but it did. Why?

Related

Linked Server Connectivity Issues?

My linked server was fine until now and i was selecting data using some join statement for filtering the but suddenly its returning following error. i cannot execute any query against my linked server.
Linked server is still available as i tried a TEST CONNECTION from server object and it was successful
Msg 65535, Level 16,State 1, Line 0
Sql Server Interface:Error Loading Server/Instance Specified
(xfffffff)
oledb provider sqlnc111 for linked server "MSNAC/MSDB5" returned an
error " A login time out expired
A network-related or instance-specific error has occurred while
establishing a connection to SQL Server. Server is not found or not
accessible. Check if instance name is correct and if SQL Server is
configured to allow remote connections. For more information see SQL
Server Books Online.
How to solve this issue ?
If nobody has made any configuration changes, your queries may be timing out because of a big data change. Try to, at least temporarily, set the following option:
USE Yourdatabase;
GO
EXEC sp_configure 'remote query timeout', 0;
GO
RECONFIGURE;
GO
If it goes fine with these settings, your queries were simply timing out because of the set limit. Experiment a bit with your queries, see what is an appropriate limit to put in this properties (leaving it to infinity isn't a good idea) and reconfigure once again.
NOTE: the number is in seconds.
To read up more on this issue, check the documentation for remote query timeout.

what is the default value for write timeout in postgres and MSSQL database connections?

I am using different databases to run my application. Recently I increased net_write_timeout value in mysql database, As I faced some timeout errors due to that. These errors are not occurred in Postgres or Mssql database.
My question is what is the equivalent flag of net_write_timeout (Mysql) for Postgres and Mssql database.
For SQL Server there are a couple of timeouts but nothing that directly corresponds to the net_write_timeout - afaik...
The default connection timeout (time allowed to connect to an instance) is 15 seconds. The default execution timeout (time allowed to execute a query etc) is 600. Connection timeout is set on the connection string, execution timeout on the connection in code, or at the server level by sp_configure
Refs: https://msdn.microsoft.com/en-AU/library/ms189040.aspx
and http://www.connectionstrings.com/all-sql-server-connection-string-keywords/

How to set query timeout using Atom Editor & Data-Atom?

I'm start using Atom with the package Data-Atom for SQL Server connection.
But I keep getting this error when I execute a query:
Results:
"Error (ETIMEOUT) - Timeout: Request failed to complete in 15000ms"
But on Visual Studio the same query executes without errors, so the server is ok I presume.
There is a way to resolve this?
Update: The connection options weren't being passed through to node-mssql but after this PR is merged they will be.
In my attempt to set the timeout to one hour I added the below to data-atom-connections.cson.
{
name: "sqlserver01"
protocol: "sqlserver"
user: "dzamo"
password: "norton"
server: "sqlserver01.localdomain"
database: "AdventureWorks"
options: "requestTimeout=36000000"
}
And nothing happened. I had to go and hardcode it in ~/.atom/packages/data-atom/node_modules/tedious/lib/connection.js to get a long-running query to work. I'll investigate this a bit more and open a bug on github.

disconnected sql server when run stored procedure

When I try to create or alter stored procedures, it automatically disconnects dbserver.
It only does so for stored procedure create,alter.
This is the error I get:
A transport-level error has occurred when receiving results from the
server. (provider: TCP Provider, error: 0 - The semaphore timeout
period has expired.)
How can I solve this issue?
I am not sure if it's the problem but check the query execution option from Tools -> Options menu and go to Query Execution - > Sql Server -> Advanced section. As shown below Disconnect after the query executes option should be unchecked.

Another ODBC Call Failed Topic

I am running Access 2010 FE and SQL Server 2005 BE.
I can execute pass through queries to my SQL Server succesfully by using DSNless connections.
During my testing phase sometimes I need to restore my database to get back to my original records so I can rerun my pass through queries. What I have found is when I run a pass through query, it creates an active connection on my SQL Server. I see the connection via the SQL Server Management Console under the MANAGEMENT | SQL Server Logs | Activity Monitor, select view processes. There I can see which process ID is being used and who is using it when I run my pass through query.
Now the only way for me to restore my database is to KILL the PROCESS e.g. Active connection
Now when I have my restored database in place and re-run the pass through query, I receive a ODBC -- Call Failed message box. I have attempted to run a procedure to refresh my querydefs but to no avail, I will still get the ODBC-- Call Failed message box when I click on those objects.
Now there are two options on how to fix this problem, which in either case I find not USER Friendly.
Restart my Access Application
Wait approx 5-10 minutes to rerun the Pass Through Query
I created a function to trap my ODBC Errors and this is what appears:
ODBC Error Number: 0
Error Description: [Microsoft][ODBC SQL Server Driver]Communication link failure
ODBC Error Number: 3146
Error Description: ODBC--call failed.
So if for some reason, I need to restart my SQL server or kill a process (Active Connection) on my SQL server while the Access Application is currently connected via ODBC, the objects created via ODBC will not perform properly till I execute the 2 workaround solutions as stated above.
Can anyone shed some advice on a solution? I appreciate any insight.
I asked a similar question some time ago, and never got a satisfactory answer. My original question is here: Force SET IDENTITY_INSERT to take effect faster from MS Access
There is a registry setting documented here for ACE that controls the timeout behavior:
ConnectionTimeout: The number of seconds a cached connection can remain idle before timing out. The default is 600 (values are of type REG_DWORD).
So as a third workaround (in addition to the two you already listed) you can change that registry setting to a shorter timeout (like 10 seconds). This is the approach I took in my answer. One caveat is that shortening the timeout may cause performance or other issues. Your mileage may vary.
See my full answer to the original question for more info.

Resources