From 239422c34cab6e835c9f8dc4b46f8c3945fe9561 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Thu, 29 Oct 2020 10:21:51 -0500 Subject: [PATCH 1/8] Resolved Akka.Remote LogSource race condition (#118) * Recreating Akka.Remote LogSource race condition added reproduction for https://github.com/akkadotnet/akka.net/issues/4579 * close #4579 for Serliog only - need to make a similar change for NLog * minor fixup --- .../Akka.Logger.Serilog.Tests.csproj | 1 + .../Bugfix4579Spec.cs | 73 +++++++++++++++++++ src/Akka.Logger.Serilog/SerilogLogger.cs | 5 +- 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 src/Akka.Logger.Serilog.Tests/Bugfix4579Spec.cs diff --git a/src/Akka.Logger.Serilog.Tests/Akka.Logger.Serilog.Tests.csproj b/src/Akka.Logger.Serilog.Tests/Akka.Logger.Serilog.Tests.csproj index 93ce473..5f3c1c8 100644 --- a/src/Akka.Logger.Serilog.Tests/Akka.Logger.Serilog.Tests.csproj +++ b/src/Akka.Logger.Serilog.Tests/Akka.Logger.Serilog.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Akka.Logger.Serilog.Tests/Bugfix4579Spec.cs b/src/Akka.Logger.Serilog.Tests/Bugfix4579Spec.cs new file mode 100644 index 0000000..83e2850 --- /dev/null +++ b/src/Akka.Logger.Serilog.Tests/Bugfix4579Spec.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Akka.Actor; +using Akka.Cluster; +using Akka.Configuration; +using Akka.Event; +using FluentAssertions; +using Serilog; +using Xunit; +using Xunit.Abstractions; + +namespace Akka.Logger.Serilog.Tests +{ + public class Bugfix4579Spec : TestKit.Xunit2.TestKit + { + public Bugfix4579Spec(ITestOutputHelper output) : base(GetConfig(), output: output) + { + global::Serilog.Log.Logger = new LoggerConfiguration() + .WriteTo.Sink(_sink) + .MinimumLevel.Information() + .CreateLogger(); + + var logSource = Sys.Name; + var logClass = typeof(ActorSystem); + + } + + private readonly TestSink _sink = new TestSink(); + + public static Config GetConfig() + { + return @"akka.actor.provider = cluster + akka.remote.dot-netty.tcp.hostname = localhost + akka.remote.dot-netty.tcp.port = 5110 + akka.cluster.seed-nodes = [""akka.tcp://test@localhost:5110""] + akka.loglevel = DEBUG + akka.loggers=[""Akka.Logger.Serilog.SerilogLogger, Akka.Logger.Serilog""]"; + } + + private class LoggerActor : UntypedActor + { + private readonly ILoggingAdapter _logger = Context.GetLogger(); // correct + + protected override void OnReceive(object message) + { + _logger.ForContext("semantic", true); + _logger.Info("My boss makes me use {msg} logging", message); + } + } + + /// + /// Reproduction of https://github.com/akkadotnet/akka.net/issues/4579 + /// + [Fact] + public async Task SerilogShouldNotCrashWhileAkkaRemoteIsBound() + { + var upProbe = CreateTestProbe(); + var semanticLogger = Sys.ActorOf(Props.Create(() => new LoggerActor())); + Sys.EventStream.Subscribe(TestActor, typeof(Info)); + Cluster.Cluster.Get(Sys).Subscribe(upProbe, ClusterEvent.SubscriptionInitialStateMode.InitialStateAsEvents, typeof(ClusterEvent.MemberUp)); + upProbe.FishForMessage(f => f is ClusterEvent.MemberUp); + Sys.Log.Info("Foo"); + Sys.Log.Info("Foo"); + semanticLogger.Tell("hit"); + semanticLogger.Tell("hit"); + var logs = ReceiveN(4); // receive all 4 logs + } + + } +} diff --git a/src/Akka.Logger.Serilog/SerilogLogger.cs b/src/Akka.Logger.Serilog/SerilogLogger.cs index 76eb4f8..b15aeda 100644 --- a/src/Akka.Logger.Serilog/SerilogLogger.cs +++ b/src/Akka.Logger.Serilog/SerilogLogger.cs @@ -23,12 +23,11 @@ namespace Akka.Logger.Serilog /// public class SerilogLogger : ReceiveActor, IRequiresMessageQueue { - private readonly ILoggingAdapter _log = Context.GetLogger(); + private readonly ILoggingAdapter _log = Logging.GetLogger(Context.System.EventStream, "SerilogLogger"); private static string GetFormat(object message) { - var logMessage = message as LogMessage; - return logMessage != null ? logMessage.Format : "{Message:l}"; + return message is LogMessage logMessage ? logMessage.Format : "{Message:l}"; } private static object[] GetArgs(object message) From 15795bc622dd9f2cee9bf68ebe7337529b4acf4e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 7 Nov 2020 21:50:36 +0100 Subject: [PATCH 2/8] Bump AkkaVersion from 1.4.10 to 1.4.11 (#119) Bumps `AkkaVersion` from 1.4.10 to 1.4.11. Updates `Akka` from 1.4.10 to 1.4.11 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.10...1.4.11) Updates `Akka.TestKit.Xunit2` from 1.4.10 to 1.4.11 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.10...1.4.11) Updates `Akka.Cluster` from 1.4.10 to 1.4.11 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.10...1.4.11) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 3b36a88..635c51e 100644 --- a/src/common.props +++ b/src/common.props @@ -14,7 +14,7 @@ 2.4.1 16.7.1 2.0.1 - 1.4.10 + 1.4.11 netcoreapp3.1 net461 netstandard2.0 From a9ac0116ad2a8d9fda12fdec407e48c870b355b5 Mon Sep 17 00:00:00 2001 From: Arjen Smits Date: Sat, 7 Nov 2020 22:08:02 +0100 Subject: [PATCH 3/8] Update Release Notes for Release 1.4.11 --- RELEASE_NOTES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 21a732b..ea46f9e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,8 @@ +#### 1.4.11 November 7 2020 #### + +* Updated to [Akka.NET v1.4.11](https://github.com/akkadotnet/akka.net/releases/tag/1.4.11) +* Resolved a Akka.Remote LogSource race condition + #### 1.4.10 October 28 2020 #### * Updated to [Akka.NET v1.4.10](https://github.com/akkadotnet/akka.net/releases/tag/1.4.10) From 1ed3391d97c891bb8aed2ad8fba92c1ece2dbfec Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 9 Nov 2020 21:58:59 +0100 Subject: [PATCH 4/8] Bump Microsoft.NET.Test.Sdk from 16.7.1 to 16.8.0 (#121) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.7.1 to 16.8.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.7.1...v16.8.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 635c51e..6e3c098 100644 --- a/src/common.props +++ b/src/common.props @@ -12,7 +12,7 @@ 2.4.1 - 16.7.1 + 16.8.0 2.0.1 1.4.11 netcoreapp3.1 From 174a5a69abcfe6e9acbd22c20b776f6c529c746d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 3 Mar 2021 12:41:20 +0100 Subject: [PATCH 5/8] Bump AkkaVersion from 1.4.11 to 1.4.16 (#127) Bumps `AkkaVersion` from 1.4.11 to 1.4.16. Updates `Akka` from 1.4.11 to 1.4.16 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.11...1.4.16) Updates `Akka.TestKit.Xunit2` from 1.4.11 to 1.4.16 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.11...1.4.16) Updates `Akka.Cluster` from 1.4.11 to 1.4.16 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.11...1.4.16) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 6e3c098..ac6d687 100644 --- a/src/common.props +++ b/src/common.props @@ -14,7 +14,7 @@ 2.4.1 16.8.0 2.0.1 - 1.4.11 + 1.4.16 netcoreapp3.1 net461 netstandard2.0 From b3f1f05a76958004fcaf36e97239e7317affb21e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 3 Mar 2021 15:32:38 +0000 Subject: [PATCH 6/8] Bump Microsoft.NET.Test.Sdk from 16.8.0 to 16.9.1 (#128) --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index ac6d687..6ae4628 100644 --- a/src/common.props +++ b/src/common.props @@ -12,7 +12,7 @@ 2.4.1 - 16.8.0 + 16.9.1 2.0.1 1.4.16 netcoreapp3.1 From a27bbe0be6efdcd9995223659ffa0c56583f869d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Mar 2021 20:55:15 +0000 Subject: [PATCH 7/8] Bump AkkaVersion from 1.4.16 to 1.4.17 (#129) --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 6ae4628..181d105 100644 --- a/src/common.props +++ b/src/common.props @@ -14,7 +14,7 @@ 2.4.1 16.9.1 2.0.1 - 1.4.16 + 1.4.17 netcoreapp3.1 net461 netstandard2.0 From 7c74196c4b69c01ca51ada6e31546642b4c880ab Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Wed, 17 Mar 2021 16:49:04 -0500 Subject: [PATCH 8/8] Added Akka.Logger.Serilog v1.4.17 release notes (#130) --- RELEASE_NOTES.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ea46f9e..f6f1e8c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,9 +1,4 @@ -#### 1.4.11 November 7 2020 #### +#### 1.4.17 March 17 2021 #### -* Updated to [Akka.NET v1.4.11](https://github.com/akkadotnet/akka.net/releases/tag/1.4.11) +* Updated to [Akka.NET v1.4.17](https://github.com/akkadotnet/akka.net/releases/tag/1.4.17) * Resolved a Akka.Remote LogSource race condition - -#### 1.4.10 October 28 2020 #### - -* Updated to [Akka.NET v1.4.10](https://github.com/akkadotnet/akka.net/releases/tag/1.4.10) -* Updated to Serilog 2.10.0