BSDDB 1.8.x is buggy?

Warren Postma embed at geocities.com
Mon Feb 14 15:21:48 EST 2000


> Perhaps, but I wouldn't use 1.8.5 in code I expected to be robust.  It has
> known bugs (was there ever a 1.8.6?), one of the main reasons for
upgrading
> to 2.x.

Hmm. I have been trying hard all day to crash it or cause it to have
problems.  I am wondering if the known bugs in this version are present in
the Win32 port of this library.

I have been exercising the bsddb unit with the following code.  Can anyone
show me something that will break bsddb? Or are the bugs too stealthy to
produce a test case?

The following test code starts with around 100 rows, and works it's way  up
to file sizes over 100 mb. If there were any duplicate key problems or core
dumps in the database, would I find them this way?

I have to ask myself, if code can work millions of times in a row, and then
fail once, what does that say about it's design?   What exactly was fixed in
2.0?   Were the fixes "one liners" and "fencepost errors", or was it a total
architecture change?

If so, is there a free disk-based robust bsddb-type key/value lookup system
in C somewhere?  MetaKit is out because it's C++.

Warren

--- [ code snippet follows ] ---

# DBTEST.PY

import bsddb
import random
import time
import string


print "BSD Database Test in Python Win32"
print


descriptions = [ "Add Rows", "Read Keys", "Shuffle", "Read Rows", "Delete
75%", "Close" ]

List1 = [ "Abc", "Def", "Ghi", "Jkl", "Mno", "Pqr", "Stu", "Vwx", "Yz" ]

List2 = [ "X123", "Y456", "Z789", "Y012", "Z345", "X678", "Y901", "Z234",
"X567" ]

# Shuffle an array like you might shuffle cards
# Note: This is intended to be Good Enough, Not Perfect.
# We limit shuffle operations to 100 per data set!
def Shuffle(ar):
 sz = len(ar)
 th = sz/2
 lp = sz/4
 if (lp > 100):
  lp = 100
        # now move a bunch of cards up or down:
        x1 = random.randrange(0,sz/2)
        x2 = random.randrange(0,sz/2)+(sz/2)
        c  = random.randrange(0,sz/4)
        ar[x1:x1+c], ar[x2:x2-c] = ar[x2:x2-c], ar[x1:x1+c]
        for k in range(0,lp):
     # do a little random substitution to kick things off
  for i in range(0,lp):
      x = random.randrange(0,th)
      y = random.randrange(th,sz)
      ar[x],ar[y] = ar[y], ar[x]




def testset(testindex,RowCount,db):
    times=[]
    starttime = time.clock()
    bytesread=0
    print "---- Storing "+`RowCount`+" rows in the database
 "+`testindex`+" ) ----"
    for n in range(0,RowCount):
     r = random.randrange(0,8)
         V = List1[r]*200
         K = List2[r]+"-"+`n`+`testindex` # avoid inorder insertion of keys
         db[K] = K+':'+V   # DB Btree-lookup Key 'K' has value 'V'

    times.append(time.clock()-starttime)

    # Get Keys
    #print "Read Keys"
    Keys = db.keys()
    N = len(Keys)

    times.append(time.clock()-starttime)

    print "Shuffling Key array... "
    Shuffle(Keys)

    times.append(time.clock()-starttime)

    print "After inserting ",RowCount," rows the Key Count is now ",
len(Keys)

    bytesread = 0
    #print "Reading Rows, in Random Order"
    for r in Keys:
        x = db[r]
        bytesread = bytesread + len(x)

    print "Bytes read = ", `bytesread`

    times.append(time.clock()-starttime)


    # Delete 75% of the data in the database:
    delcount = len(Keys) - ( len(Keys)/4 )
    for k in Keys[0:delcount]:
            del db[k]

    db.sync()
    Keys = db.keys();
    print "After deleting, the key count is ", len(Keys)

    times.append(time.clock()-starttime)

    #print "Closing"
    #print "Done"

    #times.append(time.clock()-starttime)
    print "Elapsed Times:"
    for i in range(0,5):
         print string.ljust(descriptions[i],20), ": ", times[i]
    print "-----------------"
    print


def testloop():
 db1 = bsddb.btopen( "c:/temp/TestBsdDb.db", "n" )
 for i in range(4,17):
  testset(i,long(20**(i/4.0)),db1)
 db1.close()

# main program:
testloop()






More information about the Python-list mailing list