-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add missing cluster singleton detection #7363
Add missing cluster singleton detection #7363
Conversation
src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs
Outdated
Show resolved
Hide resolved
src/contrib/cluster/Akka.Cluster.Tools/Singleton/reference.conf
Outdated
Show resolved
Hide resolved
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.
Left some comments
Success = 0, | ||
Timeout = 1, | ||
} | ||
public sealed class IdentifySingletonResult : Akka.Actor.INoSerializationVerificationNeeded |
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.
Should probably make this and the enum
private so it doesn't appear in the public API surface
@@ -61,6 +61,12 @@ akka.cluster.singleton-proxy { | |||
|
|||
# Interval at which the proxy will try to resolve the singleton instance. | |||
singleton-identification-interval = 1s | |||
|
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.
Config changes look good
@@ -37,7 +37,7 @@ namespace Akka.Cluster.Tools.Singleton | |||
/// Note that this is a best effort implementation: messages can always be lost due to the distributed nature of the actors involved. | |||
/// </remarks> | |||
/// </summary> | |||
public sealed class ClusterSingletonProxy : ReceiveActor | |||
public sealed class ClusterSingletonProxy : ReceiveActor, IWithTimers |
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.
LGTM
// ignoring the timeout tick message. | ||
if (_singleton is not null) | ||
{ | ||
Timers.Cancel(IdentifySingletonTimeOutTick.Instance); |
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 might consider adding a debug message here in case there's an actual bug that lead to this, but that's not a big deal. Good to check for this condition and just turn the timer off and return early though - LGTM
"ClusterSingletonProxy failed to find an associated singleton named [{0}] in role [{1}] after {2} seconds.", | ||
_settings.SingletonName, _settings.Role, _settings.SingletonIdentificationFailurePeriod.TotalSeconds); | ||
|
||
Context.System.EventStream.Publish(IdentifySingletonResult.Timeout( |
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.
Ah, is this why IdentifySingletonResult
is part of the public API? So apps can subscribe to it?
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.
Yes, I think it is a good addition, people can use this to detect if something went wrong in their application by hooking to this event, instead of having to check their logs
As per user request, add missing cluster singleton detection to ClusterSingletonProxy to help debug misconfigured singleton setup
Detection timer:
Changes