Use leveldb database lock for concurrent upgrade protection (fixes #703)

Doesn't work if config directories are different though