(#3026) - fix race condition in leveldb

So far I can't seem to write a test that will fail 100% of the time (or even more than 10% of the time), but I have the fix at least.

I guess we could just do like 20 Travis runs to verify this?