P
Plausible Indirection
I've been working from the assumption that all connections within a
pool should behave the same, but I'm wondering how that is possible if
some properties of the connection can be set from both the connection
string and from a property. For an example with minor effect, let's
consider PacketSize or "Packet Size".
Pooling works by making collections (pools) of connections with
identical connection strings. What if you set PacketSize and "Packet
Size" and for some connection set PacketSize to something different
from "Packet Size" after setting the connection string? Won't your
connection behave differently from others in the same pool? That
would be OK until that connection was closed at the application level,
but it could cause problems when the 'physical' connection is reused
by another public-level connection object.
I would speculate that this could be a reason why exact connection
strings are used to determine the pool into which a connection is
placed or from which it is drawn. I would guess that the implementors
of the connection pool used some form of IDictionary collection, like
maybe a Hashtable, and these collections don't like to have their key
values change. Properties can change, but the connection string as it
was when the connection is opened can provide a unique snapshot value.
The only safe way out of this that I can think of is to have the pool
manager reset all the properties of a connection to the default when
it is closed and to re-parse the connection string to re-establish the
user settings.
I'm thinking this could have performance implications for how an app
manages connection settings if something less trivial were involved,
like the database setting.
Does this make sense? Have I gone astray in this logic?
-Chris
pool should behave the same, but I'm wondering how that is possible if
some properties of the connection can be set from both the connection
string and from a property. For an example with minor effect, let's
consider PacketSize or "Packet Size".
Pooling works by making collections (pools) of connections with
identical connection strings. What if you set PacketSize and "Packet
Size" and for some connection set PacketSize to something different
from "Packet Size" after setting the connection string? Won't your
connection behave differently from others in the same pool? That
would be OK until that connection was closed at the application level,
but it could cause problems when the 'physical' connection is reused
by another public-level connection object.
I would speculate that this could be a reason why exact connection
strings are used to determine the pool into which a connection is
placed or from which it is drawn. I would guess that the implementors
of the connection pool used some form of IDictionary collection, like
maybe a Hashtable, and these collections don't like to have their key
values change. Properties can change, but the connection string as it
was when the connection is opened can provide a unique snapshot value.
The only safe way out of this that I can think of is to have the pool
manager reset all the properties of a connection to the default when
it is closed and to re-parse the connection string to re-establish the
user settings.
I'm thinking this could have performance implications for how an app
manages connection settings if something less trivial were involved,
like the database setting.
Does this make sense? Have I gone astray in this logic?
-Chris