Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt IPs may end up being duplicated #609

Open
MartinKolarik opened this issue Jan 26, 2025 · 2 comments
Open

Alt IPs may end up being duplicated #609

MartinKolarik opened this issue Jan 26, 2025 · 2 comments
Assignees

Comments

@MartinKolarik
Copy link
Member

We need a repeated check here otherwise there's a race condition because of the async call that happens between the current check and actually adding the IP to the list.

@alexey-yarmosh
Copy link
Member

alexey-yarmosh commented Feb 10, 2025

Such a check already exists here, it checks alt IPs as well:

async syncIpLimit () {
if (process.env['FAKE_PROBE_IP']) {
return;
}
const probes = await this.fetchProbes();
// Sorting probes by "client" (socket id), so all workers will treat the same probe as "first".
const sortedProbes = _.sortBy(probes, [ 'client' ]);
const ipToSocketId = new Map<string, string>();
const socketIdsToDisconnect = new Set<string>();
for (const probe of sortedProbes) {
for (const ip of [ probe.ipAddress, ...probe.altIpAddresses ]) {
const prevSocketId = ipToSocketId.get(ip);
if (prevSocketId && prevSocketId !== probe.client) {
logger.warn(`Probe ip duplication occurred (${ip}). Socket id to preserve: ${prevSocketId}, socket id to disconnect: ${probe.client}`);
socketIdsToDisconnect.add(probe.client);
} else {
ipToSocketId.set(ip, probe.client);
}
}
}

@MartinKolarik
Copy link
Member Author

That doesn't handle duplication on the same probe. I've seen several cases where a probe had the same IP listed twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants