-
Notifications
You must be signed in to change notification settings - Fork 209
Switch log line to metric for detecting hash collisions #786
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
base: master
Are you sure you want to change the base?
Switch log line to metric for detecting hash collisions #786
Conversation
When experiencing a high rate of hash collissions we're observing bad performance in the agent and we suspect the deluge of logs contributes to the problem.
this.metrics = new Metrics.Builder() | ||
.id(metricGroup) | ||
.addCounter("numHashCollisions") | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don' t think this is ever going to get registered. The underlying Router
implementation has a getMetrics
method that is used to register the metrics. You could override that here but then you would need to re-instantiate numEventsRouted
and numEventsProcessed
to make sure those metrics are still sent (and probably use a metricsGroup like the parent class to avoid a breaking change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you need to register with something like "MetricsRegistry.getInstance().registerAndGet"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gracias y'all, used the singleton to register the metrics!
long hash = hashFunction.computeHash(connectionBytes); | ||
if (ring.containsKey(hash)) { | ||
logger.error("Hash collision when computing ring. {} hashed to a value already in the ring.", connectionId + "-" + i); | ||
this.collisionsCounter.increment(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might still be nice to have logging for which connections are duplicates. Could we maybe track at the connection level (instead of the partition level) and emit one log line with all of the duplicate connections (not virtual nodes in the hash ring)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a debug log that should come out in a structure like:
{
<hash>: [
0: <first connection with hash>
1..N: <colliding connections>
]
}
I chose a debug log that we'll have to explicitly opt into because I expect the structure to be huge and potentially cause this pausing like behavior we've been seeing today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and toString()
contains all the interesting bits of info we'd need, taken from AsyncConnection.java
:
@Override
public String toString() {
return "AsyncConnection [host=" + host + ", port=" + port
+ ", groupId=" + groupId + ", slotId=" + slotId + ", id=" + id
+ "]";
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think toString will be called by the logger lib so I don't need to call it myself
Context
When experiencing a high rate of hash collisions we're observing bad performance in the agent and we suspect the deluge of logs contributes to the problem.
We still need to investigate why we're getting hash collisions (more on that below) but want to try and remediate the bad performance we're seeing first.
Regarding the hash collisions we don't suspect theres anything wrong with xx3 but think the method is receiving a large number of duplicate connections but we're still investigating.
Checklist
./gradlew build
compiles code correctly./gradlew test
passes all tests