Showing posts with label connections. Show all posts
Showing posts with label connections. Show all posts

Wednesday, March 28, 2012

Netstat TIME_WAIT on SQL Server Connections

If I understand correctly, the TIME_WAIT Status when you do a NETSTAT on the
server indicates that the connection has been closed, and it is waiting to
clear. Is that right? If so, we have a lot of SQL Server connections that
are in TIME_WAIT status mode. We may have well over 100 or so of these, and
they do not clear out very fast. Why would they stick around like that, and
how do I get them to clear out sooner? Could they potentially be causing
problems by not clearing out?
Thanks,
Jesse
Hi
Connection Pooling on the Client MDAC stack. By default the SQL Driver will
keep the connection open for 120 seconds after a "close" has been issued. If
another request comes along and it uses the same credentials to the same
server, it does not have to re-setup the TCP/IP connection. Instead it puts
it on the connection that has been around the longest in the TIME_WAIT
state.
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Jesse" <nospam@.fake.com> wrote in message
news:u9T48m3OFHA.1176@.TK2MSFTNGP12.phx.gbl...
> If I understand correctly, the TIME_WAIT Status when you do a NETSTAT on
> the server indicates that the connection has been closed, and it is
> waiting to clear. Is that right? If so, we have a lot of SQL Server
> connections that are in TIME_WAIT status mode. We may have well over 100
> or so of these, and they do not clear out very fast. Why would they stick
> around like that, and how do I get them to clear out sooner? Could they
> potentially be causing problems by not clearing out?
> Thanks,
> Jesse
>
|||I have looked into those settings, and they are set up as you stated,
however, these are staying in TIME_WAIT long after the 120 seconds. For
instance, I can log on to our server at 8:00 or 9:00 at night, when there is
no one on the server, and there are well over 100 connections left in
TIME_WAIT status. Any ideas why?
Jesse
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:Ol4H%23U5OFHA.3356@.TK2MSFTNGP12.phx.gbl...
> Hi
> Connection Pooling on the Client MDAC stack. By default the SQL Driver
> will keep the connection open for 120 seconds after a "close" has been
> issued. If another request comes along and it uses the same credentials to
> the same server, it does not have to re-setup the TCP/IP connection.
> Instead it puts it on the connection that has been around the longest in
> the TIME_WAIT state.
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "Jesse" <nospam@.fake.com> wrote in message
> news:u9T48m3OFHA.1176@.TK2MSFTNGP12.phx.gbl...
>

Netstat TIME_WAIT on SQL Server Connections

If I understand correctly, the TIME_WAIT Status when you do a NETSTAT on the
server indicates that the connection has been closed, and it is waiting to
clear. Is that right? If so, we have a lot of SQL Server connections that
are in TIME_WAIT status mode. We may have well over 100 or so of these, and
they do not clear out very fast. Why would they stick around like that, and
how do I get them to clear out sooner? Could they potentially be causing
problems by not clearing out?
Thanks,
JesseHi
Connection Pooling on the Client MDAC stack. By default the SQL Driver will
keep the connection open for 120 seconds after a "close" has been issued. If
another request comes along and it uses the same credentials to the same
server, it does not have to re-setup the TCP/IP connection. Instead it puts
it on the connection that has been around the longest in the TIME_WAIT
state.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Jesse" <nospam@.fake.com> wrote in message
news:u9T48m3OFHA.1176@.TK2MSFTNGP12.phx.gbl...
> If I understand correctly, the TIME_WAIT Status when you do a NETSTAT on
> the server indicates that the connection has been closed, and it is
> waiting to clear. Is that right? If so, we have a lot of SQL Server
> connections that are in TIME_WAIT status mode. We may have well over 100
> or so of these, and they do not clear out very fast. Why would they stick
> around like that, and how do I get them to clear out sooner? Could they
> potentially be causing problems by not clearing out?
> Thanks,
> Jesse
>|||I have looked into those settings, and they are set up as you stated,
however, these are staying in TIME_WAIT long after the 120 seconds. For
instance, I can log on to our server at 8:00 or 9:00 at night, when there is
no one on the server, and there are well over 100 connections left in
TIME_WAIT status. Any ideas why?
Jesse
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:Ol4H%23U5OFHA.3356@.TK2MSFTNGP12.phx.gbl...
> Hi
> Connection Pooling on the Client MDAC stack. By default the SQL Driver
> will keep the connection open for 120 seconds after a "close" has been
> issued. If another request comes along and it uses the same credentials to
> the same server, it does not have to re-setup the TCP/IP connection.
> Instead it puts it on the connection that has been around the longest in
> the TIME_WAIT state.
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "Jesse" <nospam@.fake.com> wrote in message
> news:u9T48m3OFHA.1176@.TK2MSFTNGP12.phx.gbl...
>

Netstat shows Port 1433 Activity

When I run Netstat it shows many connections from Port 1433 on my server to
various ports on seemingly random computers. SQL Profiler and Enterprise Man
ager do not show logins or processes that correspond to this activity. Howev
er Task Manager does show increased memory and CPU time for sqlservr.exe As
time goes on the number of netstat connections increases until I reboot the
server.
I have SP3 and also disable Port 1434.
I don't know if this is related but if I Stop and then Start MSSQLSERVER Ser
vice, then SQL doesn't seem to work until I reboot the Server.
Does anyone know what is causing these network connections? I plan to use IP
SEC to filter certain IPs and Ports to reduce this but I would like to under
stand the problem better before I try to solve it.Netstat should show you only valid IP addresses connected to 1433 on your
server.
You can use PortQuery or Port reporter to validate this as well.
832919 New features and functionality in PortQry version 2.0
http://support.microsoft.com/?id=832919
Is SQL Server behind a firewall?
Are you using Standard SQL Security ?
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.|||Kevin,
Thanks for your response.
Downloaded Port Reporter. It stated that the server did not provide process
mapping. Downloaded TCPView.
At the time I ran TCPView, instead of the usual connections on port 1433, t
here were many (about 25) established connections on port 1025, some from IP
addresses on the server that should not be establishing connections. All of
these were associated with msdtc.exe. I killed a couple of these processes.
When I killed the 2nd all the remaining disappeared. What does this indicat
e?
When I have observed many connections on port 1433 the state is usually WAIT
_STATE or FIN_2 something.
The server is a leased server at an ISP (Interland) that I administer remote
ly via Terminal Services. There are 2 NICs: 1 to their LAN and 1 to the Inte
rnet.
For firewall I hoped to use IPSEC. I assume that 'Standard SQL Security' mea
ns the same to you as to me (passwords, limit user capabilities) and the ans
wer is Yes.
If the connection state is not "ESTABLISHED' does that mean that other devic
es are attempting to connect unsuccessfully? Could these be port scanner vir
uses or similar?
The msdtc.exe ESTABLISHED connections caused me more concern. Does that mean
my server and another device were 'handshaking' or exchanging data?
Mike
quote:
Originally posted by Kevin McDonnell [MSFT]
Netstat should show you only valid IP addresses connected to 1433 on your
server.
You can use PortQuery or Port reporter to validate this as well.
832919 New features and functionality in PortQry version 2.0
http://support.microsoft.com/?id=832919
Is SQL Server behind a firewall?
Are you using Standard SQL Security ?
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.

|||Previous posting:
At the time I ran TCPView, instead of the usual connections on port
1433, there were many (about 25) established connections on port 1025,
some from IP addresses on the server that should not be establishing
connections. All of these were associated with msdtc.exe. I killed a
couple of these processes. When I killed the 2nd all the remaining
disappeared. What does this indicate?
*** MSDTC is used for Distributed Transactions. If the IP address is not
from a machine
that you "Trust" , then this machine should be blocked.
When I have observed many connections on port 1433 the state is usually
WAIT_STATE or FIN_2 something.
*** TCP sessions have various states. FIN, TIME_WAIT are all valid states.
See:
137984 TCP Connection States and Netstat Output
http://support.microsoft.com/?id=137984
The server is a leased server at an ISP (Interland) that I administer
remotely via Terminal Services. There are 2 NICs: 1 to their LAN and 1
to the Internet.
*** Your provider should also have Firewall to prevent machines
from establishing connections. If they don't you should seriously consider
Publishing SQL from ISA Server.
For firewall I hoped to use IPSEC. I assume that 'Standard SQL
Security' means the same to you as to me (passwords, limit user
capabilities) and the answer is Yes.
*** If you only have certain valid clients that should be connecting to
your SQL Server
accross the internet, then IPSEc or a VPN could be used. Otherwise, since
your server
is open and using Standard Security, you'll be open to password guessing
attacks.
If the connection state is not "ESTABLISHED' does that mean that other
devices are attempting to connect unsuccessfully? Could these be port
scanner viruses or similar?
*** See TCP Connection States kb.
The msdtc.exe ESTABLISHED connections caused me more concern. Does that
mean my server and another device were 'handshaking' or exchanging
data?
*** If your SQL Server is not using Distributed Transactions, Stop the
MSDTC Server Service.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.|||Kevin,
Thanks for your help.
Since I stopped the MSDTC Server Service the spurious connections on Port 14
33 and 1025 have not reoccurred. I still have some on Port 21 that look like
viruses trying to find an FTP connection. I'll use IPSEC to filter those.
Mikesql

Monday, March 19, 2012

Nested Parent-Child Packages

I have a fairly simple SSIS project that has nested parent-child packages.
I am trying to find the best way to manage the connections strings so as to make the package portable across machines and environments. Currently there is one "master" package which calls 6 child packages. 1 of these child package calls 3 child packages of its own.

For the database connections, I've settled on creating a standardized .dtsConfig file for each server/login. This is a relatively small number (intially 8) that I don't expect to grow much.

I've taken a different approach for the file-system connections used by Execute Package components that call the child packages. For each package that has child packages, I store all the connection strings (paths) to the child packages in a single .dtsConfig file. This works well for the top-level "master" package where I can pass in the .dtsConfig file (that has the paths to the child packages) as a run-time option in the Execute Package Utility.

However, this approach seems to fall apart for the 2nd generation package that in turn call 3rd generation packages because I don't know how to get the .dtsConfig file (with the 3rd generation .dtsx package paths) path to this downstream dtsx package.

Though I'm sure there are others, the only two solutionsI can think of now are
(a)don't nest packages beyond 1 parent/child relationship -- not really an option or
(b)Store the path of .dtsConfig files for each .dtsx package as an environment variable on each machine. This option is unappealing because it would require adding an environment variable for every .dtsx package that has child packages. I don't think it would take long for this to grow into a large number, that would make managing environment variables cumbersome.

So far my experience with SSIS has been that there was a simple solution for each scenario I had. So this hoop jumping I'm going through seems to indicate I am just missing something.

Is there a better way I am just not getting?

In a similar situation, I put all the 3rd level child packages in the same folder. Then I used a parent package configuration to pass a root path variable from the 1st level master to the second level master. I used an expression on the connectionstring property for each file system connection that concatenated the root path with the name of the package.

It worked pretty well for me, but there are some limits with parent package configurations, since they are evaluated later in the process than other types of configurations (hopefully something that will be addressed in Katmai).