Berkeley database files often tend to get corrupt. Sometimes they are still readable, but write operations fail. You can check by calling the del method instead of using the delete statement and looking at the return status value. To restore a corrupted berkeley database, you can just db_dump and db_load the file.