How can I capture queries that fail on the SQL Server due to connection drops/failures? - sql

How can I capture queries that fail on the SQL Server due to connection drops/failures?
Profiler doesnt seem to capture if there is a connectivity loss.

Without catching the exception in the code this is not the easiest thing to do.
Have you checked the error logs in SQL? DA has a related answer for doing this: https://dba.stackexchange.com/questions/10364/sql-server-error-log-monitoring
You can check that your profiler is set up correctly:
http://support.microsoft.com/kb/224587
There are a number of sql monitoring tools out there, just google 'SQL server monitoring'.

Related

I'm using a Linked Server to pull data from Google BigQuery to SQL Server using the Simba Driver but larger recordsets kill my SQL Server service

I'm running SQL Server 2016 (13.0.5850.14) with a linked server connection to Google BigQuery using the Simba BigQuery driver v2.4.1.1009 (64 bit). I have multiple queries that I'm using to bring data back to our premise operational data store. The solution works fine for small record sets but there seems to be a point where larger record sets kill the SQL Service.
One of my queries returns a record set within a few seconds when limited to 40,000 records but kills the service when returning the full record set of approx 47,000 records.
SQL traces don't show any errors, neither does the event log. The SQL log does say:
Message
SQL Server is terminating because of fatal exception 40000015. This error may be caused by an unhandled Win32 or C++ exception, or by an access violation encountered during exception handling. Check the SQL error log for any related stack dumps or messages. This exception forces SQL Server to shutdown. To recover from this error, restart the server (unless SQLAgent is configured to auto restart).
I've already extended the timeout on the connections but that doesn't seem to have made any difference and I suspect its more some sort of memory issue with the driver but I really don't know what more I can do? Appreciate any suggestions

Getting frequent "connection timeout" error on Databricks Job while connecting to Azure SQL Database

We have a clojure code that runs on Databricks, and fetches some large amount of data from Azure SQL Database.
Recently, we are getting frequent connection timeout errors.
I am new to Clojure, so I don't understand why this error occurs. Sometimes the code runs perfectly while sometimes it fails.
We have tried different connection parameters like "connectionretry" and "logintimeout" but it didn't work.
com.microsoft.sqlserver.jdbc.SQLServerException: Connection timed out (Read failed)
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
at com.microsoft.sqlserver.jdbc.SimpleInputStream.getBytes(SimpleInputStream.java:352)
at com.microsoft.sqlserver.jdbc.DDC.convertStreamToObject(DDC.java:796)
at com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:3777)
at com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:247)
at com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2054)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2040)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getObject(SQLServerResultSet.java:2372)
at clojure.java.jdbc$dft_read_columns$fn__226.invoke(jdbc.clj:457)
at clojure.core$mapv$fn__6953.invoke(core.clj:6627)
at clojure.lang.LongRange.reduce(LongRange.java:233)
at clojure.core$reduce.invokeStatic(core.clj:6544)
at clojure.core$mapv.invokeStatic(core.clj:6618)
at clojure.core$mapv.invoke(core.clj:6618)
at clojure.java.jdbc$dft_read_columns.invokeStatic(jdbc.clj:457)
at clojure.java.jdbc$dft_read_columns.invoke(jdbc.clj:453)
at clojure.java.jdbc$result_set_seq$row_values__233.invoke(jdbc.clj:483)
at clojure.java.jdbc$result_set_seq$thisfn__235.invoke(jdbc.clj:493)
at clojure.java.jdbc$result_set_seq$thisfn__235$fn__236.invoke(jdbc.clj:493)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:521)
at clojure.core$seq__4357.invokeStatic(core.clj:137)
at clojure.core$map$fn__4785.invoke(core.clj:2637)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.Cons.next(Cons.java:39)
at clojure.lang.RT.next(RT.java:688)
at clojure.core$next__4341.invokeStatic(core.clj:64)
at clojure.core$dorun.invokeStatic(core.clj:3033)
at clojure.core$doall.invokeStatic(core.clj:3039)
at clojure.core$doall.invoke(core.clj:3039)
at clojure.java.jdbc$query$fn__340$fn__341.invoke(jdbc.clj:1007)
at clojure.java.jdbc$query$fn__340.invoke(jdbc.clj:1006)
The issue isn't related to Azure SQL Database JDBC driver but the way you are establishing the connection and running queries.
Make sure you are closing the connection properly after every commit. Additionally, you have a sufficient sleep time between connections.
Also, make sure that the large data you are fetching must have required bandwidth and properly queried.
You can refer these official documentation for troubleshooting:
Troubleshooting connectivity issues and other errors with Azure SQL Database and Azure SQL Managed Instance
Resolving connectivity errors to SQL Server

See queries that hit SQL

Is there a way using sql 2008 Management Studio to look at the queries that hit the server? I'm trying to debug a program and I get messages like "Incorrect syntax near the keyword 'AND'". Since the queries are being dynamically generated it's a hassle to figure out what is going to the server.
Any help is appreciated!
There is a tool called Profiler that will tell you all information that you'll need. MSDN: http://msdn.microsoft.com/en-us/library/ms187929.aspx
I'm not aware of any method to do this using SQL Server Management Studio, but if you installed SSMS then you probably also installed the SQL Profiler. If you fire that up and run the TSQL_SPs profiler template, you can see every statement that's hitting the database.
Since the queries are being dynamically generated it's a hassle to figure out what is going to the server.
Why not just put the query that's generated into a message box, or print it to the console, or webpage, etc. ??
Trying to catch it at the DB server seems to be the long-way-around to debugging some simple ad-hoc queries.
Go to Management...Activity Monitor in the object explorer.
It's not live though, you will have to refresh it manually.
start up profiler from SSMS (Tools-->SQL Server Profiler), run a trace and select the T-SQL events
One option is to use SQL Server Profiler to run a trace. However, in some shops SQL Server permissions are set so only DBAs can run traces.
If you don't have sufficient rights to run a trace, then another option is to view the network traffic between the application that generates the SQL and box SQL Server is running on. WireShark works great for that.

ColdFusion 8: Database Connection Reset Error

I have been getting these intermittent ColdFusion Database connection reset errors and was wondering if anyone had experience with this and had a particular solution that worked?
Here is the error:
Error Executing Database Query.[Macromedia][SQLServer JDBC Driver]A problem occurred when attempting to contact the server (Server returned: Connection reset). Please ensure that the server parameters passed to the driver are correct and that the server is running. Also ensure that the maximum number of connections have not been exceeded for this server.
This doesn't happen with any particular query, the code breaks in different queries every time, returning a SQLState error 08s01. These query's logic are fine, no logic errors etc. I checked the network logs and there were no database server connection refusals at the time of the error. Once the first error occurs, it keeps happening for no more than a minute or so at random times of the day, every few days. I've googled this thing and so far anyone that has had this issue was only on CF6 or 7, which the fixes coldFusion put out are only for CF6 or 7.
Server configuration wise:
The ColdFusion server is version 8
The database server is SQL Server
2005 Standard
The database connections allowed
setting is set to unlimited on both
SQL Server and ColdFusion
Any help would be greatly appreciated, Thanks!
I'd personally try to update JDBC driver ( http://sourceforge.net/projects/jtds/ ) and add Validation Query if not already existing. I used once tool which was constantly checking TCP connections between servers, detecting even milisecond gap, check this tool http://www.colasoft.com/ping_tool/ .
Have you already resolved the issue?
I'm having the same problem on CF8 VPS, and after doing some research online I found this post:
http://www.mail-archive.com/cf-talk#houseoffusion.com/msg302264.html
It says it's related to some features on the network card and something on the SP2 for Win2k3 that messes it up. Don't know if that applies to you but just in case.

Analyze SQL Server 2005 Transaction Log using Log Parser

Is it possible to analyze SQL Server 2005 Transaction logs using LogParser 2.2? If not, what is the alternative? Red Gate's tool only analyzes SQL Server 2000 and Lumigent's Log Parser is no where to be found.
TIA
ramesh
The reason is that the log is in a proprietary and different format for 2005/2008 and MSFT has not released the specs so there are no log parsers yet that work for 2005 and 2008
If your DB is consuming 75% and your connections are all in use, you might start by checking out the activity monitor and seeing what processes are churning and/or running the profiler before you worry about the log files.
edit:
sorry, initially missed the part where you mentioned you rebooted.
You would need to attach SQL Profiler to the SQL Instance after the problem has started, but before the SQL Server stops users from connecting. Try pausing the service for a few minutes to allow some of the connections to finish and disconnect then unpause the service and see if profiler can connect.
Also try running SQL Profiler locally on the server. While remote connections may not work, local connections may.
There is a product that does what I think you are after, unfortunately its not cheap. It lets you monitor the transaction logs for SQL 2005/2008. I would love something open source but cant find anything yet.
http://www.apexsql.com/sql_tools_logapi.asp