Neruina - Ticking Entity Fixer

Neruina - Ticking Entity Fixer

26M Downloads

Concurrent Modification Exception on a weird set of events

pietro-lopes opened this issue ยท 6 comments

commented

For some reason one of our servers was having a CME every time it was saving, and was reproduceable with the command /save-all

This is the CME:

This is with a tool to easier debug CMEs:

The modpack is All The Mods Arcana 0.6

The mods involved are Neruina, Natures Aura and Productive Bees (the root erroring entity)

For this scenario, if Neruina checked first if the position of the erroring entity was loaded, this would not happen, however I don't know much about the side effects of this on your mod, so take it with a grain of salt.

If you need more info just reply here.

commented

Catching the RuntimeException in a forEach scenario is safe? won't that interrupt the iteration and cause other mods data to not be save/unexpected behavior?

remember that the CME is not thrown under your scope

commented

Ok so the issue is as follows

  1. A save request is made
  2. Neruina begins saving its persistent data
  3. Neruina queries the world for an entity's uuid to serialize it
  4. The chunk that holds the entity is unloaded so the world loads it
  5. Nature's aura intercepts chunk loads to add their aura chunk data to it
  6. Nature's aura gets their level data that is in the server's persistent storage
  7. Their level data is not present so they add it to the persistent storage
  8. Persistent storage is currently being saved (CME)

I can't stop 5 through 8 and I kinda need 4 so it's kinda unsolvable on my side other than just stopping the propagation

commented

Interacting with chunks at that low of a level is just asking for trouble

commented

I have never played with saving data and chunk stuff but if the entity of that chunk is not loaded you need to load it? if that is not loaded isn't it saved on disk as the latest possible state?

commented

Well this is curious, I'll look into it and let you know if its something I can control

commented

That should avoid this crash entirely. Which I think will actually stop all crashes related to this.
If a ticking entity occurs, its in loaded chunks so when serializing (which happens immediately) the chunk is still loaded allowing the safe getting of the uuid.
When handling unload -> reload the entity uuid is cached so the world doesn't need to be interacted again.