Can we use Hibernate for SQL permissions?
yuuka-miya opened this issue ยท 8 comments
One of the drawbacks with the current SQL provider was that it could be unreliable... for various reasons.
Is it possible to use Hibernate to save permissions instead?
If need be I'll do it myself, but some pointers would be appreciated.
Well from my experience SQL is not working properly at all. Or I would say "delete all and input defaults on server restart" is not truly good way to do stuff. It is sad because MySQL is superior for permission thingies that are to be read again and again and again..., flat files do slow down server in this manner. Or you can read from flat file efficiently when spigot cannot?
The problem is not that we are not using hibernate or any of that kind.
The problem is that to store permissions right now, we have to persist the whole set of permissions again (= delete all data + write new).
SQL is absolutely not suited for this type of storage which makes it so bad.
We would have to find a way to make it only write the changes that happened to the permissions.
This is why I would rather say to not support permissions stored in SQL at all.
TL;DR: The current SQL provider already works (nearly) as good as it could be and it's not really worth investing time in there.
@hanakocz , FE do not read perms "again and again", it read them only once. So, there's no difference in handling them, the problem is saving/reloading, apparently.
@hanakocz you are totally wrong.
MySql is not good at all for looking up permissions - the structure of the data is not really suited for that and also if permissions were to be looked up from SQL directly, the server would lag incredibly (which is why all permission are read on server start and kept in memory).
"singlejson" is currently the best format for persistance as it is fastest in loading / saving and very safe in handling. Also it is the best solution if you want to access permissions externally by loading the file from disk / web / whatever.
"flatfiles" is the next best format which should be used if manually editing permissions in files by hand is necessary.
"sql" is right now the worst because it needs to be either completely cleared on each save and then rewritten or we would have to write a custom sync code which checks which elements are different which will probably have pretty much the same performance as the delete-all-persist-all approach.
That is why I would rather completely remove SQL as supported backend because it is not only horrible for persistance of this type of changing data, but also horrible to read from - loading the JSON persisted data in PHP, JS, etc is a simple single-line action.
Exactly!
Especially because reading the SQL data externally again is so complicated, only some insane guy would do that. JSON is just one instruction and done - also there is remote interface if no direct access to the file is possible and even then there are a lot of alternatives.
With this cleared I would like to close this issue as "wontfix".
If someone else makes an PR to improve the existing SQL persistence handler, I would accept that of course. But our team won't waste time on this as there are soo many other things to improve that are actually important.
True
The only thing I would consider spending time on would be H2 and HBase support for permissions since both of those are far closer to a flat file. But that is something that is extremely low priority since my time is limited as is, and the current system works fine for most systems. Especially, since the database is kept in memory as a HashMap, the drawback of a flat file (disk speed) is negated by the efficiency of the HashMap stored in memory.