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:
[ ] An atomic flag variable that indicates if unsaved markers are present
[ ] (if necessary) thread-safety guarantees (like synchronization barriers) to prevent multiple concurrent calls to save()
[ ] Overwrite-by-rename to ensure that writes are atomic. Otherwise, a partial (and corrupt) file might be written.
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().
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:
save()
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()
.