You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Martin Kalén <mk...@apache.org> on 2005/06/01 02:41:44 UTC

Re: a problem about oracle connection leak

Wang Lei wrote:
> At first ,thank you for your reply.
> I tried it as you wrote.
> The result keeps the same.

Are you still running multithreaded test runner from the initial post?

If so, it's just a fact that you are asking for 500 brokers at approximately
the same time in your test runner (as Steve Clark pointed out).

Also, you have no way of getting reproducable results using an inherit
multithreaded race-condition where the number of threads active in parallell
is dependent on execution speed of the JVM and your hardware.
(If you monitor Oracle sessions with your multithreaded test runner,
you might see only 2 active in parallell beacuse all other threads had time
to finish,
or you might see 500 active in parallell because the for-loop with Thread
start was fast enough to start them all, but no thread is yet finished with
RBDMS-ops.)

If you want to try the semantics "acquire a broker, perform op, close broker"
sequentially 500 times to check for Connection leaks you just use a single-
threaded test runner with a for-loop instead of 500 threads.


I can't really tell which code you are running and what you still consider
to be a problem. (I realise this is a language problem, so plead bear with me
while I try to read you correctly - I am also not a native English speaker
so we have some "filtering" in both ends.) :-)

Please supply more details so we can follow up on the SequenceManager
configuration changes you posted. Most important is: exactly which test runner
code are you using at the moment and exactly what are the semantics you
are trying to test (ie how do you define your "connection leak" and what
do you think is the expected result).

Regards,
  Martin


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: a problem about oracle connection leak

Posted by Martin Kalén <mk...@apache.org>.
Martin Kalén wrote:
> Most important is: exactly which test runner
> code are you using at the moment and exactly what are the semantics you
> are trying to test

Attached you will find a slight modification of your original code that
will run two loops:
1. 500 store-ops in sequence
2. 500 store-ops spread over 20 parallell threads with 25 store-ops/thread

In part 1 you will always get 0 active brokers after each completed
store operation.

In part 2 you will get random results (completely unsynchronized,
asking for 20 parallell threads) with a maximum of 20 active brokers
at the end of each store operation.

(Completely independent on SequenceManager implementation used,
the difference in parallellism when using this unsynchronized pattern
is just a side-effect of different RDBMS roundtrip trimes/speed
between different implementations.)

At the end of part 2 you will always get 0 active brokers.

I hope this clarifies that the "leak" you saw is by design in your
test runner. The reason that you will almost always see as many active
brokers as you create thread is that it's very fast to create the
PersistenceBroker (increases active count), but takes time to connect
to DB and perform store op (=long time window of exposure before close
and decrease of active count). Number of active brokers is also not
related 1:1 to number of active Connection instances - this metric
is only available from the connection pool (and not readily available
in OJB 1.0.x, in OJB 1.1 there are monitoring calls for active/idle
connection cound from the pools).


Test conditions:
repository_database.xml
<jdbc-connection-descriptor jcd-alias="wang_lei" default-connection="false"
	username="ojb_test" password="ojb_test"
	dbalias="@127.0.0.1:1522:MARTIN"
	driver="oracle.jdbc.OracleDriver" jdbc-level="2.0"
	platform="Oracle" protocol="jdbc" subprotocol="oracle:thin"
         batch-mode="false" useAutoCommit="1">
   <object-cache class="org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl"/>
   <connection-pool
	maxActive="20" maxIdle="10" whenExhaustedAction="2" maxWait="2000"
	validationQuery="SELECT 1 FROM DUAL"
	testOnBorrow="true" testOnReturn="false" testWhileIdle="false"/>
   <!-- different sequence managers tested -->
</jdbc-connection-descriptor>

OJB.properties
maxActive=20
maxIdle=10
maxWait=2000
timeBetweenEvictionRunsMillis=-1
whenExhaustedAction=2

Other settings are standard OJB v1.0.3 release properties.
The MyTest class and table DDL is according to your original post.

Regards,
  Martin