From 677997fa9eeed6b9f741f8d0c7d68f0a137d72c2 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 4 Mar 2019 23:44:24 -0500 Subject: Remove Entity slice debug logs As per 1.13, we have no evidence these illegal states are causing issues we can identify, so just going to hide the fact its happening (but still have the code to auto fix it) --- ...340-Add-some-Debug-to-Chunk-Entity-slices.patch | 86 ---------------------- ...tor-and-detect-illegal-Entity-slice-state.patch | 76 +++++++++++++++++++ .../0347-Entity-add-to-world-fixes.patch | 14 ++-- ...port-the-dupe-uuid-and-entity-log-changes.patch | 16 ++-- 4 files changed, 91 insertions(+), 101 deletions(-) delete mode 100644 Spigot-Server-Patches/0340-Add-some-Debug-to-Chunk-Entity-slices.patch create mode 100644 Spigot-Server-Patches/0340-Monitor-and-detect-illegal-Entity-slice-state.patch diff --git a/Spigot-Server-Patches/0340-Add-some-Debug-to-Chunk-Entity-slices.patch b/Spigot-Server-Patches/0340-Add-some-Debug-to-Chunk-Entity-slices.patch deleted file mode 100644 index 271f4fb86b..0000000000 --- a/Spigot-Server-Patches/0340-Add-some-Debug-to-Chunk-Entity-slices.patch +++ /dev/null @@ -1,86 +0,0 @@ -From cb60a9794593e7752a415d3f558e8b789054c2eb Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Mon, 23 Jul 2018 22:44:23 -0400 -Subject: [PATCH] Add some Debug to Chunk Entity slices - -If we detect unexpected state, log and try to recover - -This should hopefully avoid duplicate entities ever being created -if the entity was to end up in 2 different chunk slices - -diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index ce66bb780d..2a5d1c90b4 100644 ---- a/src/main/java/net/minecraft/server/Chunk.java -+++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -681,8 +681,34 @@ public class Chunk { - entity.ab = this.locX; - entity.ac = k; - entity.ad = this.locZ; -- this.entitySlices[k].add(entity); -+ - // Paper start -+ List entitySlice = this.entitySlices[k]; -+ boolean inThis = entitySlice.contains(entity); -+ List currentSlice = entity.entitySlice; -+ if ((currentSlice != null && currentSlice.contains(entity)) || inThis) { -+ if (currentSlice == entitySlice || inThis) { -+ LogManager.getLogger().warn(entity + " was already in this chunk section! Report this to https://github.com/PaperMC/Paper/issues/1302"); -+ new Throwable().printStackTrace(); -+ return; -+ } else { -+ LogManager.getLogger().warn(entity + " is still in another ChunkSection! Report this to https://github.com/PaperMC/Paper/issues/1302"); -+ -+ Chunk chunk = entity.getCurrentChunk(); -+ if (chunk != null) { -+ if (chunk != this) { -+ LogManager.getLogger().warn(entity + " was in another chunk at that! " + chunk.locX + "," + chunk.locZ); -+ } -+ chunk.removeEntity(entity); -+ } else { -+ removeEntity(entity); -+ } -+ new Throwable().printStackTrace(); -+ } -+ } -+ entity.entitySlice = entitySlice; -+ entitySlice.add(entity); -+ - this.markDirty(); - entity.setCurrentChunk(this); - entityCounts.increment(entity.getMinecraftKeyString()); -@@ -725,6 +751,12 @@ public class Chunk { - } - - // Paper start -+ if (entity.entitySlice == null || !entity.entitySlice.contains(entity) || entitySlices[i] == entity.entitySlice) { -+ entity.entitySlice = null; -+ } else { -+ LogManager.getLogger().warn(entity + " was removed from a entitySlice we did not expect. Report this to https://github.com/PaperMC/Paper/issues/1302"); -+ new Throwable().printStackTrace(); -+ } - if (!this.entitySlices[i].remove(entity)) { return; } - this.markDirty(); - entity.setCurrentChunk(null); -@@ -955,6 +987,7 @@ public class Chunk { - } - // Spigot End - entity.setCurrentChunk(null); // Paper -+ entity.entitySlice = null; // Paper - - // Do not pass along players, as doing so can get them stuck outside of time. - // (which for example disables inventory icon updates and prevents block breaking) -diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index eb8904a728..86b0b84335 100644 ---- a/src/main/java/net/minecraft/server/Entity.java -+++ b/src/main/java/net/minecraft/server/Entity.java -@@ -59,6 +59,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper - } - } - }; -+ List entitySlice = null; - // Paper end - static boolean isLevelAtLeast(NBTTagCompound tag, int level) { - return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; --- -2.18.0 - diff --git a/Spigot-Server-Patches/0340-Monitor-and-detect-illegal-Entity-slice-state.patch b/Spigot-Server-Patches/0340-Monitor-and-detect-illegal-Entity-slice-state.patch new file mode 100644 index 0000000000..3330f5f86d --- /dev/null +++ b/Spigot-Server-Patches/0340-Monitor-and-detect-illegal-Entity-slice-state.patch @@ -0,0 +1,76 @@ +From 3e0934988343ec1ba1f5950d8302636c306ebc0d Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 23 Jul 2018 22:44:23 -0400 +Subject: [PATCH] Monitor and detect illegal Entity slice state + +If we detect unexpected state, try to recover + +This should hopefully avoid duplicate entities ever being created +if the entity was to end up in 2 different chunk slices + +diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java +index e5c900a85..e4d5e65c8 100644 +--- a/src/main/java/net/minecraft/server/Chunk.java ++++ b/src/main/java/net/minecraft/server/Chunk.java +@@ -681,8 +681,27 @@ public class Chunk { + entity.ab = this.locX; + entity.ac = k; + entity.ad = this.locZ; +- this.entitySlices[k].add(entity); ++ + // Paper start ++ List entitySlice = this.entitySlices[k]; ++ boolean inThis = entitySlice.contains(entity); ++ List currentSlice = entity.entitySlice; ++ if (inThis || (currentSlice != null && currentSlice.contains(entity))) { ++ if (currentSlice == entitySlice || inThis) { ++ return; ++ } else { ++ Chunk chunk = entity.getCurrentChunk(); ++ if (chunk != null) { ++ chunk.removeEntity(entity); ++ } else { ++ removeEntity(entity); ++ } ++ currentSlice.remove(entity); // Just incase the above did not remove from this target slice ++ } ++ } ++ entity.entitySlice = entitySlice; ++ entitySlice.add(entity); ++ + this.markDirty(); + entity.setCurrentChunk(this); + entityCounts.increment(entity.getMinecraftKeyString()); +@@ -725,6 +744,9 @@ public class Chunk { + } + + // Paper start ++ if (entity.entitySlice == null || !entity.entitySlice.contains(entity) || entitySlices[i] == entity.entitySlice) { ++ entity.entitySlice = null; ++ } + if (!this.entitySlices[i].remove(entity)) { return; } + this.markDirty(); + entity.setCurrentChunk(null); +@@ -955,6 +977,7 @@ public class Chunk { + } + // Spigot End + entity.setCurrentChunk(null); // Paper ++ entity.entitySlice = null; // Paper + + // Do not pass along players, as doing so can get them stuck outside of time. + // (which for example disables inventory icon updates and prevents block breaking) +diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java +index b761524f0..a2654690f 100644 +--- a/src/main/java/net/minecraft/server/Entity.java ++++ b/src/main/java/net/minecraft/server/Entity.java +@@ -59,6 +59,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper + } + } + }; ++ List entitySlice = null; + // Paper end + static boolean isLevelAtLeast(NBTTagCompound tag, int level) { + return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; +-- +2.21.0 + diff --git a/Spigot-Server-Patches/0347-Entity-add-to-world-fixes.patch b/Spigot-Server-Patches/0347-Entity-add-to-world-fixes.patch index 506a7aae75..e0cdf53921 100644 --- a/Spigot-Server-Patches/0347-Entity-add-to-world-fixes.patch +++ b/Spigot-Server-Patches/0347-Entity-add-to-world-fixes.patch @@ -1,4 +1,4 @@ -From 28915916c310632997ed1146e1f86bc7d89ac53e Mon Sep 17 00:00:00 2001 +From 006c7fd9553064cea0bc6a4d4dc0afb7535e6de5 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 3 Aug 2018 22:47:46 -0400 Subject: [PATCH] Entity add to world fixes @@ -14,10 +14,10 @@ Fix this by differing entity add to world for all entities at the same time the original entity is dead, overwrite it as the logic does for unloaod queued entities. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index dfa4a4bf..523d10e8 100644 +index e4d5e65c8..0a3f00c3b 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -889,6 +889,7 @@ public class Chunk { +@@ -879,6 +879,7 @@ public class Chunk { this.world.b(this.tileEntities.values()); List[] aentityslice = this.entitySlices; // Spigot int i = aentityslice.length; @@ -25,7 +25,7 @@ index dfa4a4bf..523d10e8 100644 for (int j = 0; j < i; ++j) { List entityslice = aentityslice[j]; // Spigot -@@ -936,10 +937,12 @@ public class Chunk { +@@ -926,10 +927,12 @@ public class Chunk { thisChunk.put(entity.uniqueID, entity); } } @@ -41,7 +41,7 @@ index dfa4a4bf..523d10e8 100644 } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 4a16f7ac..04d0fa1d 100644 +index 4a16f7ac7..04d0fa1df 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1204,6 +1204,7 @@ public abstract class World implements IBlockAccess { @@ -70,7 +70,7 @@ index 4a16f7ac..04d0fa1d 100644 } this.entityList.add(entity); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 1244baf4..a14b5e06 100644 +index 1244baf45..a14b5e061 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -1173,7 +1173,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { @@ -83,5 +83,5 @@ index 1244baf4..a14b5e06 100644 } else { if (!(entity instanceof EntityHuman)) { -- -2.19.1 +2.21.0 diff --git a/Spigot-Server-Patches/0364-Backport-the-dupe-uuid-and-entity-log-changes.patch b/Spigot-Server-Patches/0364-Backport-the-dupe-uuid-and-entity-log-changes.patch index 25e983ade1..cb49ba6f4d 100644 --- a/Spigot-Server-Patches/0364-Backport-the-dupe-uuid-and-entity-log-changes.patch +++ b/Spigot-Server-Patches/0364-Backport-the-dupe-uuid-and-entity-log-changes.patch @@ -1,11 +1,11 @@ -From 82ae87163d6936053ea6476cf58a3115948a1892 Mon Sep 17 00:00:00 2001 +From eb1f52537e3d7166a3d72850715cd6ec8d6c8160 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 12 Oct 2018 01:37:54 -0400 Subject: [PATCH] Backport the dupe uuid and entity log changes diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index ed147535..ba299afc 100644 +index ed1475351..ba299afc4 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -543,7 +543,7 @@ public class PaperWorldConfig { @@ -34,10 +34,10 @@ index ed147535..ba299afc 100644 case "remove": case "delete": diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 6541f5af..00c46fe5 100644 +index 4f88db79a..4060fd274 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -888,7 +888,7 @@ public class Chunk { +@@ -878,7 +878,7 @@ public class Chunk { List entityslice = aentityslice[j]; // Spigot // Paper start DuplicateUUIDMode mode = world.paperConfig.duplicateUUIDMode; @@ -46,7 +46,7 @@ index 6541f5af..00c46fe5 100644 Map thisChunk = new HashMap<>(); for (Iterator iterator = ((List) entityslice).iterator(); iterator.hasNext(); ) { Entity entity = iterator.next(); -@@ -903,27 +903,26 @@ public class Chunk { +@@ -893,27 +893,26 @@ public class Chunk { && java.util.Objects.equals(other.getSaveID(), entity.getSaveID()) && entity.getBukkitEntity().getLocation().distance(other.getBukkitEntity().getLocation()) < world.paperConfig.duplicateUUIDDeleteRange ) { @@ -80,7 +80,7 @@ index 6541f5af..00c46fe5 100644 } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index bcbdadbd..7633a613 100644 +index bcbdadbd3..7633a6134 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -45,6 +45,7 @@ public abstract class World implements IBlockAccess { @@ -92,7 +92,7 @@ index bcbdadbd..7633a613 100644 { @Override diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index b19942e0..d29420dd 100644 +index b19942e0f..d29420dd4 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -54,7 +54,6 @@ public class WorldServer extends World implements IAsyncTaskHandler { @@ -140,5 +140,5 @@ index b19942e0..d29420dd 100644 old.addedToWorldStack.printStackTrace(); } else { -- -2.19.1 +2.21.0 -- cgit v1.2.3