diff --git a/progress-tracking/src/main/java/org/neo4j/gds/core/utils/progress/BatchingProgressLogger.java b/progress-tracking/src/main/java/org/neo4j/gds/core/utils/progress/BatchingProgressLogger.java index ef70ed9f6f..005e0c70b3 100644 --- a/progress-tracking/src/main/java/org/neo4j/gds/core/utils/progress/BatchingProgressLogger.java +++ b/progress-tracking/src/main/java/org/neo4j/gds/core/utils/progress/BatchingProgressLogger.java @@ -124,7 +124,7 @@ private synchronized void doLogPercentage(Supplier msgFactory, long prog String message = msgFactory != NO_MESSAGE ? msgFactory.get() : null; progressCounter.add(progress); int nextPercentage = (int) ((progressCounter.sum() / (double) taskVolume) * 100); - if (globalPercentage < nextPercentage) { + if (globalPercentage < nextPercentage && globalPercentage < 100) { globalPercentage = nextPercentage; if (message == null || message.isEmpty()) { logProgress(nextPercentage); diff --git a/progress-tracking/src/test/java/org/neo4j/gds/core/utils/BatchingProgressLoggerTest.java b/progress-tracking/src/test/java/org/neo4j/gds/core/utils/BatchingProgressLoggerTest.java index 4fc44bf7ab..027ed7df69 100644 --- a/progress-tracking/src/test/java/org/neo4j/gds/core/utils/BatchingProgressLoggerTest.java +++ b/progress-tracking/src/test/java/org/neo4j/gds/core/utils/BatchingProgressLoggerTest.java @@ -182,6 +182,18 @@ void shouldLog100OnlyOnce() { .containsExactly("Test 100%"); } + @Test + void shouldNotExceed100Percent() { + TestLog log = Neo4jProxy.testLog(); + var testProgressLogger = new BatchingProgressLogger(log, Tasks.leaf("Test"), 1); + testProgressLogger.reset(1); + testProgressLogger.logProgress(1); // reaches 100 % + testProgressLogger.logProgress(1); // exceeds 100 % + assertThat(log.getMessages(TestLog.INFO)) + .extracting(Extractors.removingThreadId()) + .containsExactly("Test 100%"); + } + @Test void closesThreadLocal() { var logger = new BatchingProgressLogger(