Subject | Re: Multi-threaded apps and pooled connection question |
---|---|
Author | Greg At ACD |
Post date | 2005-09-07T16:43:52Z |
--- In firebird-support@yahoogroups.com, "Ann W. Harrison"
<aharrison@i...> wrote:
I am (or was) pretty sure that I am commiting correctly in all
situations, but apparently there must be an open transaction hanging
around (likely a missed commit). I do know that I issue a commit
after the Insert stored proc is called, so that's where I was
getting confused.
Probably what is happening is exactly what you say... the 2nd thread
(i.e. the one doing the SELECT) does a commit from a previous
request, and a new transaction starts immediately, but the
connection sits idle until after the insert is completed by the 1st
thread. Since the implicit transaction in the 2nd thread started
before the insert in the 1st thread, it doesn't "see" the inserted
data until it does it's own commit.
K thx for the help!
Greg
<aharrison@i...> wrote:
> Greg At ACD wrote:new
> >
> > Now, I have a situation where I have one connection service
> > an "insert into <table>..." request, and returns a PK for the
> > record ...makes
> >
> > After a short amount of time, the client then uses this PK and
> > a request to the back end (select ... from <tablewhere id = <newpk
> > value>). It so happens that a different connection is used fromthe
> > connection pool, and the call comes back with an empty result(i.e.
> > the second connection doesn't see the data that was added in theconnection
> > first connection). If I wait a second or so, then the 2nd
> > will return the correct data.the
>
> If that's happening, you're not doing your commits correctly. If
> first insert is committed, and the subsequent select is done froma
> transaction that starts after the commit, the select will see thecommitted
> results. Absolutely. My guess is that you're using a read
> transaction (which I wouldn't) and that each connection starts aperhaps
> transaction as soon as it commits the previous transaction. Or
> that connections just hang around loose with open transactions.OK, that's what I had hoped. Something that I can fix :)
>
> Regards,
>
>
> Ann
I am (or was) pretty sure that I am commiting correctly in all
situations, but apparently there must be an open transaction hanging
around (likely a missed commit). I do know that I issue a commit
after the Insert stored proc is called, so that's where I was
getting confused.
Probably what is happening is exactly what you say... the 2nd thread
(i.e. the one doing the SELECT) does a commit from a previous
request, and a new transaction starts immediately, but the
connection sits idle until after the insert is completed by the 1st
thread. Since the implicit transaction in the 2nd thread started
before the insert in the 1st thread, it doesn't "see" the inserted
data until it does it's own commit.
K thx for the help!
Greg