db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Armin Waibel" <ar...@code-au-lait.de>
Subject Re: [CVS OJB tests fail] broker leak in cache
Date Mon, 17 Feb 2003 10:21:44 GMT
Hi Jakob,

----- Original Message -----
From: "Jakob Braeuchi" <jbraeuchi@gmx.ch>
To: "OJB Developers List" <ojb-dev@db.apache.org>
Sent: Saturday, February 15, 2003 10:08 PM
Subject: Re: [CVS OJB tests fail] broker leak in cache


> guten abend armin,
>
> i did some tests to monitor the pb-pool and added the method
> getNumActive() to PersistenceBrokerFactoryIF.
> the question is where to do the monitoring ?  first try is to do it in
> tearDown of each testcase so we can immediatly see where the leakage
> comes from.
>
>     public void tearDown()
>     {
>         PersistenceBrokerFactoryIF factory =
> PersistenceBrokerFactoryFactory.instance();
>         int activeBrokers = 0;
>
>         try
>         {
>             Article a = createArticle(testId);
>             deleteArticle(a);
>             broker.clearCache();
>             broker.close();
>
>             activeBrokers = factory.getNumActive();
>             assertEquals("All Brokers should be closed", 0,
activeBrokers);
>         }
>         catch (AssertionFailedError t)
>         {
>             factory.releaseAllInstances();
>             throw t;
>         }
>     }
>
> there are two problems to be solved:
> 1) every tearDown() has to be modified
> 2) i cannot clear the pool on assertion failures, so all subsequent
> testcases will fail !

2)
I think it's not necessary to clear the pool. If we have
a broker leak all subsequent testcases should fail.

1)
Another possibility could be to start a monitor thread
in the AllTests class before the first test case was called
and kill the thread after the last test case.

/**
     * runs the suite in a junit.textui.TestRunner.
     */
    public static void main(String[] args)
    {
        String[] arr = {CLASS.getName()};
        // start the monitor
        junit.textui.TestRunner.main(arr);
        // kill the monitor
    }

Or, we extend the TestSuite class from junit and
override the
runTest(Test test, TestResult result)
method and record the pool count before
and after method call (or we add a TestListener
to TestResult).

What do you think?

regards,
Armin



>
>
> any ideas ?
>
> jakob
>
>
> Armin Waibel wrote:
>
> >Morgen Jakob,
> >
> >----- Original Message -----
> >From: "Jakob Braeuchi" <jbraeuchi@gmx.ch>
> >To: "OJB Developers List" <ojb-dev@db.apache.org>
> >Sent: Saturday, February 15, 2003 10:50 AM
> >Subject: Re: [CVS OJB tests fail] broker leak in cache
> >
> >
> >
> >
> >>hi armin,
> >>
> >>is there a testcase to detect cache leakage ?
> >>
> >>
> >
> >No, but thats a great idea! Only thing we have to do
> >is to monitor the PB-pool. Another possibility could be
> >tracking of abandoned PB in the same way as in jakarta-DBCP
> >is done.
> >
> >regards,
> >Armin
> >
> >
> >
> >>jakob
> >>
> >>Armin Waibel wrote:
> >>
> >>
> >>
> >>>----- Original Message -----
> >>>From: "Jakob Braeuchi" <jbraeuchi@gmx.ch>
> >>>To: "OJB Developers List" <ojb-dev@db.apache.org>
> >>>Sent: Friday, February 14, 2003 6:35 PM
> >>>Subject: Re: [CVS OJB tests fail] broker leak in cache
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>>hi armin,
> >>>>
> >>>>but why didn't this happen when using Identity(Object obj) which
is
> >>>>
> >>>>
> >>>>
> >>>>
> >>>also
> >>>
> >>>
> >>>
> >>>
> >>>>using the default broker behind the scenes ??
> >>>>could you please explain the details to me ?
> >>>>
> >>>>
> >>>>
> >>>>
> >>>in your implementation you forgot to call PB.close() after using
> >>>the broker, in the Identity constructor this was done.
> >>>
> >>>And I declared the Identity(Object ojb) constructor deprecated,
> >>>because when multiple databases were used the Identity was
> >>>only unique when the Identity instance knows to which database
> >>>the objects belongs (reason: we generate the PK values of the
> >>>
> >>>
> >object).
> >
> >
> >>>HTH
> >>>regards,
> >>>Armin
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>>jakob
> >>>>
> >>>>
> >>>>Armin Waibel wrote:
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>----- Original Message -----
> >>>>>From: "Jakob Braeuchi" <jbraeuchi@gmx.ch>
> >>>>>To: "OJB Developers List" <ojb-dev@db.apache.org>
> >>>>>Sent: Friday, February 14, 2003 6:03 PM
> >>>>>Subject: Re: [CVS OJB tests fail] broker leak in cache
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>hi armin,
> >>>>>>
> >>>>>>i do not understand why it worked before.
> >>>>>>new Identity(Object obj) also uses the default broker.
> >>>>>>
> >>>>>>  public Identity(Object objectToIdentitify)
> >>>>>>  {
> >>>>>>      PersistenceBroker broker = null;
> >>>>>>      try
> >>>>>>      {
> >>>>>>          broker =
> >>>>>>PersistenceBrokerFactory.defaultPersistenceBroker();  <<<<
> >>>>>>          init(objectToIdentitify, broker, null);
> >>>>>>...
> >>>>>>
> >>>>>>where's the difference ? can you please explain this to me...
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>your implementation cause a broker leak. The obtained PB
instances
> >>>>>never be closed.
> >>>>>
> >>>>>regards,
> >>>>>Armin
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>jakob
> >>>>>>
> >>>>>>Armin Waibel wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>Hi Jakob,
> >>>>>>>
> >>>>>>>----- Original Message -----
> >>>>>>>From: "Jakob Braeuchi" <jbraeuchi@gmx.ch>
> >>>>>>>To: "OJB Developers List" <ojb-dev@db.apache.org>
> >>>>>>>Sent: Friday, February 14, 2003 5:17 PM
> >>>>>>>Subject: Re: [CVS OJB tests fail] broker leak in cache
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>hi armin,
> >>>>>>>>
> >>>>>>>>did it work _before_ my changes ? if yes i could undo
them.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>yes it worked without your changes.
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>a) remove the public void cache(Object obj)
> >>>>>>>>i agree. this method is imo never used in ojb.
> >>>>>>>>
> >>>>>>>>b) change method remove(Object obj)
> >>>>>>>>i think this should be ok
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>ok, I'm started to make these changes
> >>>>>>>in the cache package.
> >>>>>>>
> >>>>>>>regards,
> >>>>>>>Armin
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>jakob
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>Armin Waibel wrote:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>Hi all,
> >>>>>>>>>
> >>>>>>>>>in CVS ObjectCacheDefaultImpl we had
> >>>>>>>>>a PB leak.
> >>>>>>>>>This is caused by using PBF.defaultPB calls
> >>>>>>>>>without closing the broker. Jakob add this to avoid
> >>>>>>>>>using of deprecated Identity constructor.
> >>>>>>>>>But the real problem is that this solution never
> >>>>>>>>>will work, because of using the default broker.
> >>>>>>>>>
> >>>>>>>>>Thus I propose the following changes in ObjectCache:
> >>>>>>>>>a) remove the
> >>>>>>>>>public void cache(Object obj) throws
> >>>>>>>>>ClassNotPersistenceCapableException;
> >>>>>>>>>method, this will never work.
> >>>>>>>>>
> >>>>>>>>>b) change method
> >>>>>>>>>public void remove(Object obj);
> >>>>>>>>>to
> >>>>>>>>>public void remove(Identity oid);
> >>>>>>>>>
> >>>>>>>>>What do you think?
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>regards,
> >>>>>>>>>Armin
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
>
>>>>>>------------------------------------------------------------------
-
> >>>>>>
> >>>>>>
> >-
> >
> >
> >>>>>>>
> >>>>>>>
> >>>-
> >>>
> >>>
> >>>
> >>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >>>>>>>>>For additional commands, e-mail: ojb-dev-help@db.apache.org
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
>
>>>>>-------------------------------------------------------------------
-
> >>>>>
> >>>>>
> >-
> >
> >
> >>>>>>
> >>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >>>>>>>>For additional commands, e-mail: ojb-dev-help@db.apache.org
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
>
>>>>>-------------------------------------------------------------------
-
> >>>>>
> >>>>>
> >-
> >
> >
> >>>>>>
> >>>>>>
> >>>>>>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >>>>>>>For additional commands, e-mail: ojb-dev-help@db.apache.org
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
>
>>>>--------------------------------------------------------------------
-
> >>>>
> >>>>
> >>>>>
> >>>>>
> >>>>>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >>>>>>For additional commands, e-mail: ojb-dev-help@db.apache.org
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
>
>>>>--------------------------------------------------------------------
-
> >>>>
> >>>>
> >>>>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >>>>>For additional commands, e-mail: ojb-dev-help@db.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
>
>>>---------------------------------------------------------------------
> >>>
> >>>
> >>>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >>>>For additional commands, e-mail: ojb-dev-help@db.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
>
>>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >>>For additional commands, e-mail: ojb-dev-help@db.apache.org
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
>
>>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-dev-help@db.apache.org
> >>
> >>
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> >For additional commands, e-mail: ojb-dev-help@db.apache.org
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
>


Mime
View raw message