Browsing null value with SoftRefs?

  • Anonymous

    Anonymous - 2011-10-03

    Is there a possibility, using SoftReferences as the cache type, that browsing a BTree may return nulls inside Tuple values? I wondered if there was a possible race condition that a value could be GC'd during browsing.

    I set up my record manager as so:

    props.setProperty(RecordManagerOptions.CACHE_TYPE, RecordManagerOptions.SOFT_REF_CACHE);


    TupleBrowser<Long, String> browser = getTree().browse( null ); // position browser at end of the list
    while ( browser.getPrevious( tuple ) ) {
        String mightBeNull = tuple.getValue();

    Sometimes in the above code, mightBeNull comes back null. Is this a known issue? My code above is simplified but I don't think anything I left out should affect the core actions of reverse browsing the tree.

  • Kevin Day

    Kevin Day - 2011-10-03

    We have used soft_ref_cache in over 300 high production sites for nearly 7 years.  I have never seen the behavior that you describe.

    One possible cause of your issue:  are you locking your interaction with the database properly?  Each individual action on the BTree is synchronized (so internal state is kept consistent), but when you do something like a tuple iteration, the overall iteration itself is not synchronized.  We wound up having to create our own locking infrastructure to ensure that we didn't get unexpected behavior when performing operations that span multiple recman calls.

  • Anonymous

    Anonymous - 2011-10-06

    Probably not - I'll check that out… thanks.


Log in to post a comment.