From e61b8a4d9b5dd1aff35df5f6cb1707fb4982bd7b Mon Sep 17 00:00:00 2001 From: Intelli Date: Sat, 11 May 2024 13:06:29 -0600 Subject: [PATCH] Fixed unnecessary database transactions when consumer is empty (fixes #511) --- .../java/net/coreprotect/consumer/process/Process.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/net/coreprotect/consumer/process/Process.java b/src/main/java/net/coreprotect/consumer/process/Process.java index 563549d..44bd127 100755 --- a/src/main/java/net/coreprotect/consumer/process/Process.java +++ b/src/main/java/net/coreprotect/consumer/process/Process.java @@ -83,6 +83,14 @@ public class Process { int consumerDataSize = consumerData.size(); currentConsumerSize = consumerDataSize; + if (currentConsumerSize == 0) { // No data, skip processing + updateLockTable(statement, (lastRun ? 0 : 1)); + statement.close(); + Consumer.consumer_id.put(processId, new Integer[] { 0, 0 }); + Consumer.isPaused = false; + return; + } + Database.beginTransaction(statement); // Scan through usernames, ensure everything is loaded in memory. for (Entry entry : users.entrySet()) { @@ -225,6 +233,7 @@ public class Process { consumerData.remove(index); } currentConsumerSize = 0; + Consumer.consumer_id.put(processId, new Integer[] { 0, 0 }); Consumer.isPaused = false; return; }