Update db.cpp

Incorporate locks exhaustion fix per https://github.com/CryptoManiac/novacoin/commit/16e1262471dba899f3e9251b485abec219aec844