Add write lock for goroutines to make leveldb thread safe