Skip to content

Disabled cache lets run SQL commands on the main thread #2112

@TuxCoding

Description

@TuxCoding

Background:
For inventory protection, we are checking every time the inventory is changed if the user is registered (If not logged in). In #2109 we found out that if caching is disabled this runs directly a database query on the main thread. Despite this being bad practice, this runs for every packet, so possible a lot of times and effect the performance very easily.

Solution:
This part is found at numerous places like event listeners, so the easy solution to just run it asynchronous is useless. In the configuration we recommend disable the cache for BungeeCord and website registration. This highlights why we cannot just let it enabled.

However in case of BungeeCord we already request refreshes on something like password changes to other servers using plugin messages, still currently not registering. For website registration we could periodically refresh the data or use something like Redis. We already do the first one every 5 minutes if caching is enabled. The best solution would be to have single task that refreshes it depending on a last updated timestamp for all players.

=> Ultimately we have to cache the result of a player not registered too.

What is your recommendation? Do I miss here something?

EDIT: Added using plugin messages and explained that 5 minute refresh is only activated when using the cache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: criticalMarks issues that should be fixed/closed as soon as possible.Type: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions