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.
{
    if (!fDbEnvInit)
        return;
    fDbEnvInit = false;
    int ret = dbenv->close(0);
    if (ret != 0)
        LogPrintf("CDBEnv::EnvShutdown: Error %d shutting down database environment: %s\n", ret, DbEnv::strerror(ret));
    if (!fMockDb)
        DbEnv((u_int32_t)0).remove(strPath.c_str(), 0);
}
void CDBEnv::Reset()
{
    dbenv.reset(new DbEnv(DB_CXX_NO_EXCEPTIONS));
    fDbEnvInit = false;
    fMockDb = false;
}
CDBEnv::CDBEnv()
{
    Reset();
}
CDBEnv::~CDBEnv()
{
    EnvShutdown();
}
void CDBEnv::Close()
{
    EnvShutdown();
}
bool CDBEnv::Open(const fs::path& pathIn, bool retry)