You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/12/14 19:03:40 UTC

[GitHub] [nifi] mark-bathori opened a new pull request, #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

mark-bathori opened a new pull request, #6783:
URL: https://github.com/apache/nifi/pull/6783

   <!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
   <!-- contributor license agreements.  See the NOTICE file distributed with -->
   <!-- this work for additional information regarding copyright ownership. -->
   <!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
   <!-- (the "License"); you may not use this file except in compliance with -->
   <!-- the License.  You may obtain a copy of the License at -->
   <!--     http://www.apache.org/licenses/LICENSE-2.0 -->
   <!-- Unless required by applicable law or agreed to in writing, software -->
   <!-- distributed under the License is distributed on an "AS IS" BASIS, -->
   <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
   <!-- See the License for the specific language governing permissions and -->
   <!-- limitations under the License. -->
   
   # Summary
   
   [NIFI-10974](https://issues.apache.org/jira/browse/NIFI-10974)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [x] Build completed using `mvn clean install -P contrib-check`
     - [x] JDK 8
     - [ ] JDK 11
     - [ ] JDK 17
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] NissimShiman commented on pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
NissimShiman commented on PR #6783:
URL: https://github.com/apache/nifi/pull/6783#issuecomment-1367926251

   reviewing..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] NissimShiman commented on a diff in pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
NissimShiman commented on code in PR #6783:
URL: https://github.com/apache/nifi/pull/6783#discussion_r1059474644


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java:
##########
@@ -218,7 +218,11 @@ public void onTrigger(final ReportingContext context) {
         }
 
         final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
-        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
+        final String percentageThreshold = threshold.substring(0, threshold.length() - 1);

Review Comment:
   Maybe rename to percentageUsageThreshold



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] mark-bathori commented on a diff in pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
mark-bathori commented on code in PR #6783:
URL: https://github.com/apache/nifi/pull/6783#discussion_r1068189478


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java:
##########
@@ -218,7 +218,11 @@ public void onTrigger(final ReportingContext context) {
         }
 
         final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
-        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
+        final String percentageThreshold = threshold.substring(0, threshold.length() - 1);
+        final double usageThreshold = Double.parseDouble(percentageThreshold);
+        // In certain scenarios in the monitored memory bean the gcSensor can get stuck in 'on' state before the usage would reach the threshold
+        // and this will cause false exceeded state until the next garbage collection. To eliminate this we are adding a condition with the calculated usage threshold.
+        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded() && percentageUsed > usageThreshold) {

Review Comment:
   Yes that's what I meant.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] NissimShiman commented on a diff in pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
NissimShiman commented on code in PR #6783:
URL: https://github.com/apache/nifi/pull/6783#discussion_r1067124628


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java:
##########
@@ -218,7 +218,11 @@ public void onTrigger(final ReportingContext context) {
         }
 
         final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
-        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
+        final String percentageThreshold = threshold.substring(0, threshold.length() - 1);
+        final double usageThreshold = Double.parseDouble(percentageThreshold);
+        // In certain scenarios in the monitored memory bean the gcSensor can get stuck in 'on' state before the usage would reach the threshold
+        // and this will cause false exceeded state until the next garbage collection. To eliminate this we are adding a condition with the calculated usage threshold.
+        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded() && percentageUsed > usageThreshold) {

Review Comment:
   So if I understand you correctly, you are leaving this in intentionally, as further protection for the false alert.
   That sounds good to me.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] mark-bathori commented on a diff in pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
mark-bathori commented on code in PR #6783:
URL: https://github.com/apache/nifi/pull/6783#discussion_r1066964607


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java:
##########
@@ -218,7 +218,11 @@ public void onTrigger(final ReportingContext context) {
         }
 
         final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
-        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
+        final String percentageThreshold = threshold.substring(0, threshold.length() - 1);

Review Comment:
   Yes it describes better the purpose of the variable,  I'll rename it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] mark-bathori commented on a diff in pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
mark-bathori commented on code in PR #6783:
URL: https://github.com/apache/nifi/pull/6783#discussion_r1081178611


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java:
##########
@@ -218,7 +218,11 @@ public void onTrigger(final ReportingContext context) {
         }
 
         final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
-        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
+        final String percentageUsageThreshold = threshold.substring(0, threshold.length() - 1);

Review Comment:
   @tpalfy thanks for noticing this issue, I forgot to handle scenarios where memory size is provided as threshold instead of percentage.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] mark-bathori commented on a diff in pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
mark-bathori commented on code in PR #6783:
URL: https://github.com/apache/nifi/pull/6783#discussion_r1066961930


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java:
##########
@@ -218,7 +218,11 @@ public void onTrigger(final ReportingContext context) {
         }
 
         final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
-        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
+        final String percentageThreshold = threshold.substring(0, threshold.length() - 1);
+        final double usageThreshold = Double.parseDouble(percentageThreshold);
+        // In certain scenarios in the monitored memory bean the gcSensor can get stuck in 'on' state before the usage would reach the threshold
+        // and this will cause false exceeded state until the next garbage collection. To eliminate this we are adding a condition with the calculated usage threshold.
+        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded() && percentageUsed > usageThreshold) {

Review Comment:
   I wanted to keep the gcSensor and MemoryPoolMXBean side calculation and additionally calculate the threshold on NiFi side to make sure that the warning message is raised if both side calculation is the same. What do you think about this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] tpalfy commented on a diff in pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
tpalfy commented on code in PR #6783:
URL: https://github.com/apache/nifi/pull/6783#discussion_r1072345355


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java:
##########
@@ -218,7 +218,11 @@ public void onTrigger(final ReportingContext context) {
         }
 
         final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
-        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
+        final String percentageUsageThreshold = threshold.substring(0, threshold.length() - 1);

Review Comment:
   Unfortunately the `percentageUsageThreshold` determination logic is flawed.
   The user can provide an absolute value (like `100 MB`). We get a NumberFormatException in that case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] NissimShiman commented on a diff in pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by GitBox <gi...@apache.org>.
NissimShiman commented on code in PR #6783:
URL: https://github.com/apache/nifi/pull/6783#discussion_r1059474487


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java:
##########
@@ -218,7 +218,11 @@ public void onTrigger(final ReportingContext context) {
         }
 
         final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
-        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
+        final String percentageThreshold = threshold.substring(0, threshold.length() - 1);
+        final double usageThreshold = Double.parseDouble(percentageThreshold);
+        // In certain scenarios in the monitored memory bean the gcSensor can get stuck in 'on' state before the usage would reach the threshold
+        // and this will cause false exceeded state until the next garbage collection. To eliminate this we are adding a condition with the calculated usage threshold.
+        if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded() && percentageUsed > usageThreshold) {

Review Comment:
   I don't think we need check for bean.isCollectionUsageThresholdExceeded() anymore



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] tpalfy commented on pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by "tpalfy (via GitHub)" <gi...@apache.org>.
tpalfy commented on PR #6783:
URL: https://github.com/apache/nifi/pull/6783#issuecomment-1404932359

   LGTM
   Thanks for your work @mark-bathori and for the review @NissimShiman !
   Merged to main.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] turcsanyip closed pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory

Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip closed pull request #6783: NIFI-10974: Incorrect warning message on memory usage from MonitorMemory
URL: https://github.com/apache/nifi/pull/6783


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org