-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[Directory] Strengthen single activation guarantees even further. #9958
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
Open
ledjon-behluli
wants to merge
8
commits into
dotnet:main
Choose a base branch
from
ledjon-behluli:grain_leases
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+653
−120
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7ff6e8d
grain and range lease holds for even stronger single activation guran…
ledjon-behluli 387b230
address PR feedback
ledjon-behluli 3b44971
remove while enumerating
ledjon-behluli 1840151
Update src/Orleans.Core.Abstractions/Exceptions/DirectoryLeaseHoldExc…
ledjon-behluli 4cc2c48
Minor typo fixes
ReubenBond 0865588
Add lease hold test coverage for graceful shutdown, disabled leases, …
ReubenBond 6a92076
Fix hang: add DirectoryResult.RetryAfter for lease hold backoff
ReubenBond 578720b
Replace DirectoryLeaseHoldException with DirectoryResult.RetryAfter
ReubenBond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
182 changes: 100 additions & 82 deletions
182
src/Orleans.Runtime/Configuration/Options/GrainDirectoryOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,99 +1,117 @@ | ||
|
|
||
| using System; | ||
| using Orleans.Runtime.GrainDirectory; | ||
|
|
||
| namespace Orleans.Configuration | ||
| namespace Orleans.Configuration; | ||
|
|
||
| public class GrainDirectoryOptions | ||
| { | ||
| public class GrainDirectoryOptions | ||
| /// <summary> | ||
| /// Configuration type that controls the type of the grain directory caching algorithm that silo use. | ||
| /// </summary> | ||
| public enum CachingStrategyType | ||
| { | ||
| /// <summary> | ||
| /// Configuration type that controls the type of the grain directory caching algorithm that silo use. | ||
| /// </summary> | ||
| public enum CachingStrategyType | ||
| { | ||
| /// <summary>Don't cache.</summary> | ||
| None, | ||
| /// <summary>Standard fixed-size LRU.</summary> | ||
| LRU, | ||
| /// <summary>Adaptive caching with fixed maximum size and refresh. This option should be used in production.</summary> | ||
| [Obsolete("Adaptive caching is deprecated in favor of LRU and will be removed in a future version. This value is now an alias for LRU.")] | ||
| Adaptive, | ||
| /// <summary>Custom cache implementation, configured by registering an <see cref="IGrainDirectoryCache"/> implementation in the dependency injection container.</summary> | ||
| Custom | ||
| } | ||
| /// <summary>Don't cache.</summary> | ||
| None, | ||
| /// <summary>Standard fixed-size LRU.</summary> | ||
| LRU, | ||
| /// <summary>Adaptive caching with fixed maximum size and refresh. This option should be used in production.</summary> | ||
| [Obsolete("Adaptive caching is deprecated in favor of LRU and will be removed in a future version. This value is now an alias for LRU.")] | ||
| Adaptive, | ||
| /// <summary>Custom cache implementation, configured by registering an <see cref="IGrainDirectoryCache"/> implementation in the dependency injection container.</summary> | ||
| Custom | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the caching strategy to use. | ||
| /// The options are None, which means don't cache directory entries locally; | ||
| /// LRU, which indicates that a standard fixed-size least recently used strategy should be used; and | ||
| /// Adaptive, which indicates that an adaptive strategy with a fixed maximum size should be used. | ||
| /// The LRU strategy is used by default. | ||
| /// </summary> | ||
| public CachingStrategyType CachingStrategy { get; set; } = DEFAULT_CACHING_STRATEGY; | ||
| /// <summary> | ||
| /// Gets or sets the caching strategy to use. | ||
| /// The options are None, which means don't cache directory entries locally; | ||
| /// LRU, which indicates that a standard fixed-size least recently used strategy should be used; and | ||
| /// Adaptive, which indicates that an adaptive strategy with a fixed maximum size should be used. | ||
| /// The LRU strategy is used by default. | ||
| /// </summary> | ||
| public CachingStrategyType CachingStrategy { get; set; } = DEFAULT_CACHING_STRATEGY; | ||
|
|
||
| /// <summary> | ||
| /// The default value for <see cref="CachingStrategy"/>. | ||
| /// </summary> | ||
| public const CachingStrategyType DEFAULT_CACHING_STRATEGY = CachingStrategyType.LRU; | ||
| /// <summary> | ||
| /// The default value for <see cref="CachingStrategy"/>. | ||
| /// </summary> | ||
| public const CachingStrategyType DEFAULT_CACHING_STRATEGY = CachingStrategyType.LRU; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum number of grains to cache directory information for. | ||
| /// </summary> | ||
| public int CacheSize { get; set; } = DEFAULT_CACHE_SIZE; | ||
| /// <summary> | ||
| /// Gets or sets the maximum number of grains to cache directory information for. | ||
| /// </summary> | ||
| public int CacheSize { get; set; } = DEFAULT_CACHE_SIZE; | ||
|
|
||
| /// <summary> | ||
| /// The default value for <see cref="CacheSize"/>. | ||
| /// </summary> | ||
| public const int DEFAULT_CACHE_SIZE = 1_000_000; | ||
| /// <summary> | ||
| /// The default value for <see cref="CacheSize"/>. | ||
| /// </summary> | ||
| public const int DEFAULT_CACHE_SIZE = 1_000_000; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the initial (minimum) time, in seconds, to keep a cache entry before revalidating. | ||
| /// </summary> | ||
| [Obsolete("InitialCacheTTL is deprecated and will be removed in a future version.")] | ||
| public TimeSpan InitialCacheTTL { get; set; } = DEFAULT_INITIAL_CACHE_TTL; | ||
| /// <summary> | ||
| /// Gets or sets the initial (minimum) time, in seconds, to keep a cache entry before revalidating. | ||
| /// </summary> | ||
| [Obsolete("InitialCacheTTL is deprecated and will be removed in a future version.")] | ||
| public TimeSpan InitialCacheTTL { get; set; } = DEFAULT_INITIAL_CACHE_TTL; | ||
|
|
||
| /// <summary> | ||
| /// The default value for <see cref="InitialCacheTTL"/>. | ||
| /// </summary> | ||
| [Obsolete("DEFAULT_INITIAL_CACHE_TTL is deprecated and will be removed in a future version.")] | ||
| public static readonly TimeSpan DEFAULT_INITIAL_CACHE_TTL = TimeSpan.FromSeconds(30); | ||
| /// <summary> | ||
| /// The default value for <see cref="InitialCacheTTL"/>. | ||
| /// </summary> | ||
| [Obsolete("DEFAULT_INITIAL_CACHE_TTL is deprecated and will be removed in a future version.")] | ||
| public static readonly TimeSpan DEFAULT_INITIAL_CACHE_TTL = TimeSpan.FromSeconds(30); | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum time, in seconds, to keep a cache entry before revalidating. | ||
| /// </summary> | ||
| [Obsolete("MaximumCacheTTL is deprecated and will be removed in a future version.")] | ||
| public TimeSpan MaximumCacheTTL { get; set; } = DEFAULT_MAXIMUM_CACHE_TTL; | ||
| /// <summary> | ||
| /// Gets or sets the maximum time, in seconds, to keep a cache entry before revalidating. | ||
| /// </summary> | ||
| [Obsolete("MaximumCacheTTL is deprecated and will be removed in a future version.")] | ||
| public TimeSpan MaximumCacheTTL { get; set; } = DEFAULT_MAXIMUM_CACHE_TTL; | ||
|
|
||
| /// <summary> | ||
| /// The default value for <see cref="MaximumCacheTTL"/>. | ||
| /// </summary> | ||
| [Obsolete("DEFAULT_MAXIMUM_CACHE_TTL is deprecated and will be removed in a future version.")] | ||
| public static readonly TimeSpan DEFAULT_MAXIMUM_CACHE_TTL = TimeSpan.FromSeconds(240); | ||
| /// <summary> | ||
| /// The default value for <see cref="MaximumCacheTTL"/>. | ||
| /// </summary> | ||
| [Obsolete("DEFAULT_MAXIMUM_CACHE_TTL is deprecated and will be removed in a future version.")] | ||
| public static readonly TimeSpan DEFAULT_MAXIMUM_CACHE_TTL = TimeSpan.FromSeconds(240); | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the factor by which cache entry TTLs should be extended when they are found to be stable. | ||
| /// </summary> | ||
| [Obsolete("CacheTTLExtensionFactor is deprecated and will be removed in a future version.")] | ||
| public double CacheTTLExtensionFactor { get; set; } = DEFAULT_TTL_EXTENSION_FACTOR; | ||
| /// <summary> | ||
| /// Gets or sets the factor by which cache entry TTLs should be extended when they are found to be stable. | ||
| /// </summary> | ||
| [Obsolete("CacheTTLExtensionFactor is deprecated and will be removed in a future version.")] | ||
| public double CacheTTLExtensionFactor { get; set; } = DEFAULT_TTL_EXTENSION_FACTOR; | ||
|
|
||
| /// <summary> | ||
| /// The default value for <see cref="CacheTTLExtensionFactor"/>. | ||
| /// </summary> | ||
| [Obsolete("DEFAULT_TTL_EXTENSION_FACTOR is deprecated and will be removed in a future version.")] | ||
| public const double DEFAULT_TTL_EXTENSION_FACTOR = 2.0; | ||
| /// <summary> | ||
| /// The default value for <see cref="CacheTTLExtensionFactor"/>. | ||
| /// </summary> | ||
| [Obsolete("DEFAULT_TTL_EXTENSION_FACTOR is deprecated and will be removed in a future version.")] | ||
| public const double DEFAULT_TTL_EXTENSION_FACTOR = 2.0; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the time span between when we have added an entry for an activation to the grain directory and when we are allowed | ||
| /// to conditionally remove that entry. | ||
| /// Conditional deregistration is used for lazy clean-up of activations whose prompt deregistration failed for some reason (e.g., message failure). | ||
| /// This should always be at least one minute, since we compare the times on the directory partition, so message delays and clcks skues have | ||
| /// to be allowed. | ||
| /// </summary> | ||
| public TimeSpan LazyDeregistrationDelay { get; set; } = DEFAULT_UNREGISTER_RACE_DELAY; | ||
| /// <summary> | ||
| /// Gets or sets the time span between when we have added an entry for an activation to the grain directory and when we are allowed | ||
| /// to conditionally remove that entry. | ||
| /// Conditional deregistration is used for lazy clean-up of activations whose prompt deregistration failed for some reason (e.g., message failure). | ||
| /// This should always be at least one minute, since we compare the times on the directory partition, so message delays and clcks skues have | ||
| /// to be allowed. | ||
| /// </summary> | ||
| public TimeSpan LazyDeregistrationDelay { get; set; } = DEFAULT_UNREGISTER_RACE_DELAY; | ||
|
|
||
| /// <summary> | ||
| /// The default value for <see cref="LazyDeregistrationDelay"/>. | ||
| /// </summary> | ||
| public static readonly TimeSpan DEFAULT_UNREGISTER_RACE_DELAY = TimeSpan.FromMinutes(1); | ||
| } | ||
| /// <summary> | ||
| /// The default value for <see cref="LazyDeregistrationDelay"/>. | ||
| /// </summary> | ||
| public static readonly TimeSpan DEFAULT_UNREGISTER_RACE_DELAY = TimeSpan.FromMinutes(1); | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the duration for the safety lease hold applied after an ungraceful silo failure. | ||
| /// This duration applies in two scenarios: | ||
| /// <list type="bullet"> | ||
| /// <item>When a specific silo crashes ungracefully, grain lease holds prevent individual re-registration of its grains for this duration.</item> | ||
| /// <item>When a directory partition can not acquire a snapshot from a previous owner, range lease holds prevent new registrations in that whole range for this duration.</item> | ||
| /// </list> | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Depending on the value of this, the duration is understood as: | ||
| /// <list type="bullet"> | ||
| /// <item><c>SafetyLeaseHoldDuration > TimeSpan.Zero</c> - The lease duration is explicitly controlled by the user.</item> | ||
| /// <item><c>SafetyLeaseHoldDuration = TimeSpan.Zero</c>. No leases are placed at all, effectively nullifying this safety option.</item> | ||
| /// <item><c>SafetyLeaseHoldDuration = null</c> - The system computes a lease duration as: | ||
| /// <c>2 × <see cref="ClusterMembershipOptions.ProbeTimeout"/> × <see cref="ClusterMembershipOptions.NumMissedProbesLimit"/></c>. | ||
| /// This is the default value, and is designed to be long enough to allow for failure detection and cluster stabilization. | ||
| /// </item> | ||
| /// </list> | ||
| /// </remarks> | ||
| public TimeSpan? SafetyLeaseHoldDuration { get; set; } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Typo in XML doc comment: "silo use" should be "silos use".
This issue also appears on line 86 of the same file.