Test failed with Berkerley DB 4.5,may be Berkerley DB BUG?

Yunqiao YinYunqiao Yin Member Yin YunqiaoOrganization: BaosteelProject: real time process control system ✭✭
the failed test case is test/Freeze/dbmap,when testing sorting...,I got
MapI.cpp:258: Freeze::DatabaseException:
Dbc::get: Dbt not large enough for available data: DB_BUFFER_SMALL: User memory too small for return value
The error occured when call IteratorHelperI::find(const Key&), when I add
dbKey.set_ulen(dbKey.get_size());
,the test is fine.

I notice that the dbKey is initialized by initializeInDbt(Key,Dbt) function,in initializeInDbt, ulen is set to 0.
according to Berkerley DB manual,the will be fine,I think this may be Berkerley DB's bug. But for the 'In Dbt' should be keep unchanged,so if we set_ulen() equal to set_size() maybe ok,too. Isn't It?

Comments

  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    Note that we do not officially support BerkeleyDB 4.5 yet. However, we have been updating to the latest packages for the next release of Ice and ran into this problem ourselves. My colleague applied a fix for this issue yesterday, so I'll let him outline the fix.
  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    In order to get Ice to work with DB 4.5.x I changed the implementation of Freeze::IteratorHelperI::find in Freeze/MapI.cpp to use the same method as, for example, the lowerBound() method to resize the key if Berkeley throws a DB_BUFFER_SMALL database exception. IE...
        for(;;)
        {
            try
            {
                if(_dbc->get(&dbKey, &dbValue, DB_SET) == 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch(const ::DbDeadlockException& dx)
            {
                if(_tx != 0)
                {
                    _tx->dead();
                }
    
                DeadlockException ex(__FILE__, __LINE__);
                ex.message = dx.what();
                throw ex;
            }
            catch(const ::DbException& dx)
            {
                handleDbException(dx, const_cast<Key&>(key), dbKey, __FILE__, __LINE__);
            }
        }
    
  • Yunqiao YinYunqiao Yin Member Yin YunqiaoOrganization: BaosteelProject: real time process control system ✭✭
    Thank you very much for your help!
  • rGloryrGlory Member Vyacheslav KononenkoOrganization: PrivateProject: Distributed Financial Application
    Please note that dbmap::count( key ) has the same issue. There is workaround: dbmap.find( key ) != dbmap.end() which works fine
Sign In or Register to comment.