jpenilla / squaremap-addons

Various addons for squaremap
12 stars 14 forks source link

squaremap-signs: markers not persisted if server exits uncleanly #81

Open cbs228 opened 5 months ago

cbs228 commented 5 months ago

squaremap-signs from e2c3c8c3e0e97e46668bf2a4e05b4771c5ce474d, and likely newer versions, does not save its markers to disk if the game server exits uncleanly. I am using it with squaremap v1.2.3-14-g7d998a9 on Paper, but I suspect this doesn't matter.

As far as I can determine, the method which saves the markers is only invoked when the provider is unloaded in LayerProviderManager::unloadProvider(). If the server is not shut down properly, this does not happen.

A potential solution would be to periodically flush the markers database to disk. I recommend:

We could save the marker file periodically with a timer. I'm not familiar enough with the addon API to know if an appropriate timer event exists. Can we hook into the server's own periodic save logic somehow?

I noticed this issue only because my container framework was incorrectly tearing down my server with a SIGKILL instead of closing it cleanly via RCON. If you are experiencing apparent data loss from squaremap-signs markers not being persisted, check your logs to ensure your server is shutting down cleanly. If not, fix the problem! It will be good for the overall health of your world.

EDIT: it is not clear to me how events are delivered to the plugin for processing. If events can arrive on more than one thread, thread-safety behavior will be very important for save().