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.
DB_INIT_LOG |
                             DB_INIT_MPOOL |
                             DB_INIT_TXN |
                             DB_THREAD |
                             DB_RECOVER |
                             nEnvFlags,
                         S_IRUSR | S_IWUSR);
    if (ret != 0) {
        dbenv->close(0);
        LogPrintf("CDBEnv::Open: Error %d opening database environment: %s\n", ret, DbEnv::strerror(ret));
        if (retry) {
            
            fs::path pathDatabaseBak = pathIn / strprintf("database.%d.bak", GetTime());
            try {
                fs::rename(pathLogDir, pathDatabaseBak);
                LogPrintf("Moved old %s to %s. Retrying.\n", pathLogDir.string(), pathDatabaseBak.string());
            } catch (const fs::filesystem_error&) {
                
            }
            
            if (!Open(pathIn, false)) {
                
                return false;
            }
        } else {
            return false;
        }
    }
    fDbEnvInit = true;
    fMockDb = false;