Ban Management

Ban Management

193k Downloads

FEATURE: safe mode for offline database

moo-im-a-cow opened this issue ยท 7 comments

commented

hi
we have a network,
one server is hosted on the same machine as the mysql database, but the rest of the network is on a separate machine.
when the machine with the mysql db goes offline, banmanager is disabled on all the servers except the one on the same machine
all the commands break until a server restart.

my suggestion is this:
instead of disabling the plugin, put it into a "safe mode" where every 5 minutes, it re tries to connect to the database,
while its in the safe mode, have basic local support for /ban and /ipban (just the important ones, dont need the rest while in safe mode) so we can still use those commands.
when someone tries any command, tell them that it is in safe mode, and it will try soon,

once it succeeds in connecting to the database, it comes out of the safe mode, enables full support for all commands, and starts working normally

EDIT: basically i want it to try to connect to the database again, instead of shutting itself down

commented

I thought BanManager already does that. If not, I like the idea to try reconnect a few times before failing.
Maybe add a notifications for admins ingame that the database connection has been lost and will try to reinitiate.

commented

@EvilOlaf i like that idea,
maybe banmanager tries to reconnect 5 times, then it gives up,
every time an admin joins and every time bm fails to connect, admins get a message,
once ban manager gives up after 5 tries, it sends a message to admins telling them that they can reset the try count back to 0, thus making it try 5 more times

commented

BanManager will attempt to reconnect whilst the minecraft instance is running. It will only disable itself if it cannot connect on startup, in which case is the correct thing to do, as that is when it builds its in-memory cache of bans etc. Without that, it'll fail to function.

Your database server shutting down in production sounds incredibly bad. If that happens, then you should expect things to start failing, like BanManager.

In what scenarios would you ever need to shut down your database server in a production environment? The machine that hosts the Frostcast MySQL database has been online for more than 370 days now, without any incidents. If your database goes down often, I would recommend you speak with your host.

What you're asking for would be a lot of work, with very little benefit. Essentially you want BanManager to handle states where the connection is not available at start up, and to constantly attempt to connect to the database. During this time, banned players will be able to join. Whilst v4 and below used to use the vanilla banning system as a fallback, due to the UUID changes, that actually caused a lot of issues due to side effects added by the Bukkit team, so I removed it to avoid any future problems caused by it. I could implement a file based cache local to each server, but then additional problems arise with that in terms of synchronisation. At that point, BM may as well not even use an SQL database, as it is gaining little to no benefits from one, as it'll become heavily I/O dependent (which is slow), except for passing data between servers without depending on a proxy like bungee or lilypad.

commented

@confuser
the reason the database is so unreliable is because its hosted on a small laptop sitting on my desk in my bedroom

how you put it made me realise that the only person this would benefit would be me,
theres no point adding it if its for 1 person only and it would increase the load on servers using the plugin

thanks anyway ๐Ÿ‘

commented

I would defiantly benefit from this
@robrobk

commented

Regardless if there are changes in this case you really should think about hosting your database somewhere else ^^. There are quite cheap virtual private servers (about 3$/month) that could do the job.

commented

If you are hosting the database locally on your machine, chances are you run a very small server. I'd say that BanManager is not really the right solution for you, as having an additional database makes not much sense in a small environment.