As of #11466 we no longer have any logic to prevent a user from opening a wallet twice in two instances simultaneously. Not only could this break BDB (without the -privdb=false option, which I have really no idea why we even have a tuneable option for that), but we certainly don't have logic to handle such a case gracefully. It was noted in the original PR's description, but somehow was never followed up on before merge.
#include <wallet/db.h>
#include <addrman.h>
#include <hash.h>
#include <protocol.h>
#include <util.h>
#include <utilstrencodings.h>
#include <wallet/walletutil.h>
#include <stdint.h>
#ifndef WIN32
#include <sys/stat.h>
#endif
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/thread.hpp>
namespace {
void CheckUniqueFileid(const CDBEnv& env, const std::string& filename, Db& db)