From 5e414022ea8c50527870d07c953ee0ba7883553c Mon Sep 17 00:00:00 2001 From: Antti Koponen Date: Tue, 13 Oct 2026 11:31:10 +0300 Subject: [PATCH 1/2] Reload entity spawn lookups in bulk after each database commit --- .../net/coreprotect/consumer/process/Process.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/coreprotect/consumer/process/Process.java b/src/main/java/net/coreprotect/consumer/process/Process.java index 2d48c472e..215b16bba 100755 --- a/src/main/java/net/coreprotect/consumer/process/Process.java +++ b/src/main/java/net/coreprotect/consumer/process/Process.java @@ -193,6 +193,7 @@ protected static void processConsumer(int processId, boolean lastRun) { boolean hasEntityContainerTransactions = false; boolean hasEntityInteractions = false; List entitySpawnUpdateData = new ArrayList<>(); + List entitySpawnUpdateIndexes = new ArrayList<>(); Set entityIdentityUuids = new HashSet<>(); Set entityIdentityRowIds = new HashSet<>(); for (int index = 0; index < consumerDataSize; index++) { @@ -236,6 +237,7 @@ else if (action == Process.ENTITY_SPAWN_UPDATE || action == Process.ENTITY_CONTA continue; } entitySpawnUpdateData.add(spawnData); + entitySpawnUpdateIndexes.add(index); if (spawnData.getPreviousUuid() != null) { entityIdentityUuids.add(spawnData.getPreviousUuid()); } @@ -268,7 +270,6 @@ else if (action == Process.ENTITY_SPAWN_UPDATE || action == Process.ENTITY_CONTA entitySpawnUpdates = hasEntitySpawnUpdates ? writeBatch.entitySpawnUpdates() : null; if (entitySpawnUpdates != null) { entitySpawnUpdates.prefetch(entitySpawnUpdateData); - entitySpawnUpdateData.clear(); } processingStarted = true; for (int i = 0; i < consumerDataSize; i++) { @@ -556,6 +557,15 @@ else if (existingSpawnIdentity == null) { retryConsumerBatch(processId, consumerData, users, consumerObject, processedThrough); return; } + if (entitySpawnUpdates != null) { + int firstRemaining = 0; + while (firstRemaining < entitySpawnUpdateIndexes.size() && entitySpawnUpdateIndexes.get(firstRemaining) <= i) { + firstRemaining++; + } + if (firstRemaining < entitySpawnUpdateData.size()) { + entitySpawnUpdates.prefetch(new ArrayList<>(entitySpawnUpdateData.subList(firstRemaining, entitySpawnUpdateData.size()))); + } + } } } catch (Exception e) { From ce103ae257fe7ddefd558ae3c3e7f90ad6b52d70 Mon Sep 17 00:00:00 2001 From: Antti Koponen Date: Wed, 14 Oct 2026 09:27:18 +0300 Subject: [PATCH 2/2] Trim consumed prefixes after successful commit --- .../java/net/coreprotect/consumer/process/Process.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/coreprotect/consumer/process/Process.java b/src/main/java/net/coreprotect/consumer/process/Process.java index 215b16bba..8f656c0db 100755 --- a/src/main/java/net/coreprotect/consumer/process/Process.java +++ b/src/main/java/net/coreprotect/consumer/process/Process.java @@ -562,8 +562,12 @@ else if (existingSpawnIdentity == null) { while (firstRemaining < entitySpawnUpdateIndexes.size() && entitySpawnUpdateIndexes.get(firstRemaining) <= i) { firstRemaining++; } - if (firstRemaining < entitySpawnUpdateData.size()) { - entitySpawnUpdates.prefetch(new ArrayList<>(entitySpawnUpdateData.subList(firstRemaining, entitySpawnUpdateData.size()))); + if (firstRemaining > 0) { + entitySpawnUpdateIndexes.subList(0, firstRemaining).clear(); + entitySpawnUpdateData.subList(0, firstRemaining).clear(); + } + if (!entitySpawnUpdateData.isEmpty()) { + entitySpawnUpdates.prefetch(entitySpawnUpdateData); } } }