-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check restriction status only on cache #2358
base: master
Are you sure you want to change the base?
Conversation
Fixes #2212 In #2112, we found out that in configurations with disabled cache (like Bungee), this adapter will perform blocking queries on the main thread which impacts the performance. The original code (81cf14f) is in place to preserve the inventory for unregistered and configurations without enforcing a registration (#1830, #1752). Alternatives are: 1. Send the inventory on registration like p.updateInventory() * Still hides it before for unregistered 2. Checking for the enforce registration setting would mean it hides also the inventory for unregistered players 3. Get a notification on player status changes * Requires a complex setup to propagate the changes across spigot servers or different solution for web interfaces * Refresh events, when the status is updated within the plugin itself would be possible, however requires previous queries like registration/login requests. Instant reports about registration will still be complicated. Example: Every time we make queries, save the result locally and fire an event for our components to check for potential changes without making the same query again. Nevertheless this again delays changes if there is no need to that.
faeeefd
to
25f7e13
Compare
Fixes #2112 |
Very pragmatic, looks great to me! Thanks |
Okay it's not that easy. I forgot the following case: DataSource not cached, registration not enforced: |
Cache registration status for online players. The cache stays valid until the player leaves the server or logs manual in.
Since the Downside is that changes from other sources like websites won't be available until the player joins the server again. An alternative could be cache every |
Looks good to me |
I think I should add some unit tests too, because this is critical area. Just to be sure ;) |
@games647 hello, any news on this? |
Argh, I was too busy with other stuff. I'll try on Thursday. |
@games647 re-bump? 😄 |
@games647 re-re-bump 🙃 |
@sgdc3 In fact working on it now. |
Test are ready. However I encountered a race condition. When preventing the inventory data to be sent the status of the registration status isn't loaded yet. Therefore we should always prevent it at this stage. My issue is creating a good design. Currently we fire a EDIT: However this could cause a change semantics that maybe some plugins depend on. |
I see no other solution, it is a minor breaking change but I think the performance gains are more important. |
@ljacqu do you agree, what's your opinion on this? |
@games647 hello? 😅 |
TL;DR Registration status will only be checked if the data source is cached to prevent blocking SQL queries on the main thread. Another solution would be a plugin wide notification system when we query the player status, but it's more complex. See more details below at Refresh events.
@ljacqu, I tried to preserve your behavior from this comment. Therefore the proposed changes will still show the inventory for unregistered players, however only if we use the local cache.
Commit desc:
In #2112, we found out that in configurations with disabled cache (like Bungee), this adapter will perform blocking queries on the main thread which impacts the performance.
The original code (81cf14f) is in place to
preserve the inventory for unregistered and configurations without enforcing a registration (#1830, #1752). Alternatives are:
or different solution for web interfaces
So the best solution is to use the cache if available and if not fallback to safe defaults.