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.
There isn't anything in the DB right now. I setup a few test keys and delete them. And when it doesn't work properly I delete the .db and start again. So the DB can't be corrupted because I always have a new one. del didn't seem to remove the hash key.