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.
{
    
    fs::path lock_file_path = env_path / ".walletlock";
    FILE* file = fsbridge::fopen(lock_file_path, "a"); 
    if (file) fclose(file);
    try {
        static boost::interprocess::file_lock lock(lock_file_path.string().c_str());
        if (!lock.try_lock()) {
            return false;
        }
    } catch (const boost::interprocess::interprocess_exception& e) {
        return error("Error obtaining lock on wallet directory %s: %s.", env_path.string(), e.what());
    }
    return true;
}
} 
CDBEnv bitdb;
void CDBEnv::EnvShutdown()