Problem with bsddb on NT

rdev at my-deja.com rdev at my-deja.com
Wed Jun 30 20:18:57 CEST 1999


From: rdev at my-deja.com

I've been using bsddb on both Unix
and NT and I found a very serious bug
on the NT side:

Using database opened with btopen:

If I write random length records using
a six byte key (arbitrary), the bsddb
will crash with a protection exception
after writing, typically, between 50 and
5000 records.

Using database openend with hashopen:

Same test as above, but rather than
crashing with a protection exception,
it generates a python exception as follows:
Traceback (innermost last):
  File "Prog\bsddb_test.py", line 52, in ?
    test ()
  File "Prog\bsddb_test.py", line 49, in test
    adb[key] = rec
bsddb.error: (0, 'No error')

It's easy to recreate using the test program below.
It works just fine on Unix but dies quickly on NT.

If anyone has any ideas at all, please help.  This
is a critical problem and I can't seem to find any
workaround.

Test Program:

import random
import bsddb
import os

# Test overview:
#
# Write a random length record between 1 and 1000 bytes,
# using a 6 byte random valued
# key.  Repeat until the database crashes (typically between
# 50 and 5000 writes.
#
# Crashes in different ways depending on whether bsddb was
# opened as btree or hash database.


def test ():
        count = 0
        # Remove any old database in order to start clean
        try:
                os.remove('test.db')
        except:
                pass
        # Either open bsddb in hash mode or btree mode.
        # Each fails in its own way.
        adb = bsddb.btopen ('test.db', 'c')
        #adb = bsddb.hashopen ('test.db', 'c')
        # Generate a long constant string (1001 chars)
        longstring1 = 'a' * 1001
        while 1:
                # Generate a large random string
                num = random.random()
                longstring = str(int(num * 1000000)) * 200
                # Pick a record length from 1 to 1000
                reclen = int(random.random() * 1000) + 1
                # Use a keylen of 6 (arbitrary)
                keylen = 6
                #if keylen + reclen > 214:
                #       continue

                # Generate a key by taking the first keylen chars
                # from the long string
                key = longstring[:keylen]
                # Generate a record by taking the first reclen chars
                # from the constant string (contents don't matter here)
                rec = longstring1[:reclen]
                count = count + 1
                print 'count = ', count
                print 'lengths = ', keylen, reclen, keylen + reclen
                print 'Key = ', key
                # Add it to the database
                adb[key] = rec


test ()


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list