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

Fix FastKillOnCancelKeyPress not stopping the process. #3935

Merged
merged 6 commits into from
Feb 2, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
using Orleans.Runtime;
using Orleans.Runtime.Configuration;

namespace Orleans.Clustering.AzureStorage
{
// Validator to validate Azure table membership settings
public class AzureTableMembershipConfigurationValidator : IConfigurationValidator
{
private GlobalConfiguration configuration;

public AzureTableMembershipConfigurationValidator(GlobalConfiguration configuration)
{
this.configuration = configuration;
}

public void ValidateConfiguration()
{
if (string.IsNullOrEmpty(this.configuration.ClusterId))
{
throw new OrleansConfigurationException($"Invalid Configuration. ClusterId value is required.");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Orleans.Clustering.AzureStorage;
using Orleans.Hosting;
using Orleans.Runtime.Configuration;

Expand All @@ -16,6 +17,9 @@ public void ConfigureServices(object configuration, IServiceCollection services)
options.MaxStorageBusyRetries = reader.GetPropertyValue<int>("MaxStorageBusyRetries");
options.ConnectionString = reader.GetPropertyValue<string>("DataConnectionString");
});

services.AddTransient<IConfigurationValidator>(sp => new AzureTableMembershipConfigurationValidator(configuration));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the above IConfigurationValidator change seem orthogonal to this PR - maybe they should be moved into a separate PR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I am new to this. I thought checking this into my fork would not affect this pull request. This issue is something else. When ClusterId is not set you get a Azure Storage Error "Bad Request". I was had to figure out what was wrong. This check-in was meant for my branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to apologize :)
You can revert those changes in this branch and they'll disappear from here.

If you'd like assistance, let me know.


}
}
}
11 changes: 9 additions & 2 deletions src/Orleans.Runtime/Silo/Silo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -811,15 +811,22 @@ private void HandleProcessExit(object sender, EventArgs e)
// NOTE: We need to minimize the amount of processing occurring on this code path -- we only have under approx 2-3 seconds before process exit will occur
logger.Warn(ErrorCode.Runtime_Error_100220, "Process is exiting");

var cancellationSource = new CancellationTokenSource();
lock (lockable)
{
if (!this.SystemStatus.Equals(SystemStatus.Running)) return;

this.SystemStatus = SystemStatus.Stopping;

// force a non-graceful stop
cancellationSource.Cancel();
this.siloLifecycle.OnStop(cancellationSource.Token); // don't wait for it to stop
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this OnStop call here when OnStop will be called via StopAsync below?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the OnStop after call will get into the mode that just waits for State to Terminate, but nothing signals the lifecycle to stop.

}

logger.Info(ErrorCode.SiloStopping, "Silo.HandleProcessExit() - starting to FastKill()");
Stop();

// calling stop when SystemStatus is already Stopping will wait until status Terminated
StopAsync(cancellationSource.Token).GetAwaiter().GetResult();
}

internal void RegisterSystemTarget(SystemTarget target)
Expand Down