Re: Connection Pooling nastiness



I was preparing a reply for you when I again carefully studied our logs of an
incident where we see a "beautiful" chain of request 1 having a
command.timeout, request 2 receiving request 1's result, and finally request
3 receiving request 2's result. Then I suddenly noticed that request 1 was on
a different webserver than request 2 and 3.
So basically that's blown a whole in my theory of blaming Connection
Pooling. (I'm not aware that Sql Server is aware of connection pooling at the
client side). And also in anything we're doing on the client-side, such as
with static data as you suggested.

Now the only suspect would suddenly seem to be Sql Server. Even more
unlikely...

Nick


"Patrice" wrote:

What kind of application is this ? For ASP.NET application, this is caused
most often by using static data (that is they are shared by all users).

Don't know for details but I've never have seen someone reporting such a
behavior caused by how connections are handled. IMO your best bet is to
expose the raw facts and give some more details about your application
before looking at a lower level....

--
Patrice

"Nick" <SaintNick@xxxxxxxxxxxxx> a écrit dans le message de news:
B732463D-F5F9-4325-9EBA-4EA402246090@xxxxxxxxxxxxxxxx
Who can prove that the following cannot happen:

1. client A gets an ADO.Net/SqlClient connection from the connection pool
2. client A fires a TSQL batch (select a,b,c from x) at Sql Server 2K5
3. Sql Server goes to work but the are some locked resources
4. ADO.Net loses patience and times out on Connection.CommandTimeout and
throws an exception to the client
5. client A catches the exception, "closes" the connection, thus returning
it to the pool
6. client B now gets handed the the same connection from the pool, for
which
the pool fires an sp_reset_connection over that connection
8. the sp_reset_connection command gets queued and the supposedly clean
connection gets handed to client B
9. client B fires its TSQL batch (select d,e,f from z) at the connection
and
awaits results

we now have the following situation on that one same connection:
-Sql Server is still busy with client A's TSQL batch
-after which it will execute the queued sp_reset
-after which it will get round to client B's TSQL batch

what if now the following occurs:

10. Sql Server finally finishes client A's TSQL batch and signals the
connection that there are results to be fetched.
11. ADO.Net receives that signal and consumes the results and passes them
to
the awaiting client
12. The client, expecting results (d,e,f) instead receives (a,b,c)

Pretty ugly huh?

I'm not certain of my speculations on the exact proceedings of the first
11
steps, but we certainly see step 12.

Is it by design that this the default behaviour of ADO.Net connection
pooling? Or is it documented somewhere that a command.timeout exception
should be handled in some way to avoid this happening?




.



Relevant Pages

  • Re: Performance Issue with Runtime Image
    ... >> the client, closes the connection, then dies. ... request before even accepting the next incoming connection. ... The client program is unaffected so presumably the server is ...
    (comp.lang.smalltalk.dolphin)
  • Re: [PHP] $_SERVER["REMOTE_ADDR"] returning ::1
    ... Proxies can be implemented as shared clusters such that any request going through the cluster could appear to come from one of a number of IPs (i.e. the client is not tied to a single proxy appliance). ... This is unlikely however because I believe most ISPs will do everything they can to issue a connection with the same IP when the lease expires but it's not something you can rely on. ... Request it with an IPv6 domain/IP and REMOTE_ADDR will also be IPv6. ...
    (php.general)
  • Re: Connection Error: ADO.Net and SQL Server 2005
    ... Hitchhiker's Guide to Visual Studio and SQL Server ... I can connect to the server through an ODBC connection ... It is very puzzling because this client doesn't seem to have anything ...
    (microsoft.public.sqlserver.connect)
  • RE: Error 17835 - When encryption and Shared Memory are enabled
    ... Did you encounter this error when you connected to your SQL Server ... Did your SQL Server instance use a certificate explicitly specified by ... you configure your client connection settings "Force Protocol Encryption" ...
    (microsoft.public.sqlserver.connect)
  • Re: Async TCPClients
    ... especially if there will be a limited number of client connections, ... can establish a connection, so some asynchronous code is still required. ... be able to handle more than one request simealtaneously. ... o.BeginAsync immediately after o.EndAsync to start listening for another ...
    (microsoft.public.dotnet.general)

Quantcast