From 3e1217184babd94c32495f481bcf2fb5a79899ca Mon Sep 17 00:00:00 2001 From: MK Software Date: Thu, 18 Apr 2024 14:00:14 +0200 Subject: [PATCH 1/4] fix --- ...chronousExecutionContextAndIORuntime.scala | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala b/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala index 011dc699265..397216c2b59 100644 --- a/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala +++ b/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala @@ -19,13 +19,15 @@ object SynchronousExecutionContextAndIORuntime extends LazyLogging { }) private def createSyncIORuntime(): IORuntime = { - IORuntime( - compute = syncEc, - blocking = syncEc, - scheduler = DummyScheduler, - shutdown = () => {}, - config = IORuntimeConfig() - ) + withDisableCatsTracingMode { + IORuntime( + compute = syncEc, + blocking = syncEc, + scheduler = DummyScheduler, + shutdown = () => {}, + config = IORuntimeConfig() + ) + } } // note: we provide a dummy implementation of scheduler, because IORuntime requires some. We don't want to use real @@ -49,4 +51,16 @@ object SynchronousExecutionContextAndIORuntime extends LazyLogging { override def monotonicNanos(): Long = System.nanoTime() } + // note: even if the provided by us IORuntime is dummy, it registers MBean for a sake of monitoring fibers. We don't + // need it, so we just disable it. There is no other way to do it by setting system property. After IORuntime + // creation we clear the property (to not affect creating other /not existing currently/ IORuntimes) + private def withDisableCatsTracingMode(create: => IORuntime): IORuntime = synchronized { + System.setProperty("cats.effect.tracing.mode", "NONE") + try { + create + } finally { + System.clearProperty("cats.effect.tracing.mode") + } + } + } From da3a32c3519dd0dcc754986008f64910713357e1 Mon Sep 17 00:00:00 2001 From: MK Software Date: Thu, 18 Apr 2024 14:07:21 +0200 Subject: [PATCH 2/4] added: changelog --- docs/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Changelog.md b/docs/Changelog.md index 4cd859647f8..82f125a3e3f 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -15,6 +15,7 @@ * [#5853](https://github.com/TouK/nussknacker/pull/5853) Add processing mode information and filtering to the components table * [#5843](https://github.com/TouK/nussknacker/pull/5843) Added new endpoint to provide statistics URL * [#5873](https://github.com/TouK/nussknacker/pull/5873) Handle list of the anonymous statistic URLs, and send them in the interval +* [#5898](https://github.com/TouK/nussknacker/pull/5898) fixed Nu runtime memory leak 1.14.0 (21 Mar 2024) ------------------------- From a65c3307ede2715f99dd95a4eda5d155b33f4c80 Mon Sep 17 00:00:00 2001 From: MK Software Date: Thu, 18 Apr 2024 14:15:48 +0200 Subject: [PATCH 3/4] review fixes --- .../util/SynchronousExecutionContextAndIORuntime.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala b/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala index 397216c2b59..96a97a6b007 100644 --- a/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala +++ b/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala @@ -55,11 +55,16 @@ object SynchronousExecutionContextAndIORuntime extends LazyLogging { // need it, so we just disable it. There is no other way to do it by setting system property. After IORuntime // creation we clear the property (to not affect creating other /not existing currently/ IORuntimes) private def withDisableCatsTracingMode(create: => IORuntime): IORuntime = synchronized { - System.setProperty("cats.effect.tracing.mode", "NONE") + val tracingModePropertyName = "cats.effect.tracing.mode" + val originalTracingMode = Option(System.getProperty(tracingModePropertyName)) + System.setProperty(tracingModePropertyName, "NONE") try { create } finally { - System.clearProperty("cats.effect.tracing.mode") + originalTracingMode match { + case Some(mode) => System.setProperty(tracingModePropertyName, mode) + case None => System.clearProperty(tracingModePropertyName) + } } } From 38eb72c27f31b33b69e4a54f166292ade4d91915 Mon Sep 17 00:00:00 2001 From: MK Software Date: Thu, 18 Apr 2024 14:17:06 +0200 Subject: [PATCH 4/4] note --- .../engine/util/SynchronousExecutionContextAndIORuntime.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala b/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala index 96a97a6b007..49dd0bac965 100644 --- a/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala +++ b/utils/utils/src/main/scala/pl/touk/nussknacker/engine/util/SynchronousExecutionContextAndIORuntime.scala @@ -53,7 +53,8 @@ object SynchronousExecutionContextAndIORuntime extends LazyLogging { // note: even if the provided by us IORuntime is dummy, it registers MBean for a sake of monitoring fibers. We don't // need it, so we just disable it. There is no other way to do it by setting system property. After IORuntime - // creation we clear the property (to not affect creating other /not existing currently/ IORuntimes) + // creation we clear the property (to not affect creating other /not existing currently/ IORuntimes). Note that + // we change here the global state, so this is not a bullet proof solution. private def withDisableCatsTracingMode(create: => IORuntime): IORuntime = synchronized { val tracingModePropertyName = "cats.effect.tracing.mode" val originalTracingMode = Option(System.getProperty(tracingModePropertyName))