mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-12 18:31:24 +01:00
Fix issue where Plan holds server enable if database is slow
Affects issues: - Fixed #2356
This commit is contained in:
parent
c1537681ab
commit
0538cea8be
@ -20,6 +20,7 @@ import com.djrapitops.plan.SubSystem;
|
||||
import com.djrapitops.plan.delivery.domain.auth.User;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries;
|
||||
@ -39,6 +40,7 @@ import java.util.stream.Collectors;
|
||||
@Singleton
|
||||
public class TabCompleteCache implements SubSystem {
|
||||
|
||||
private final Processing processing;
|
||||
private final PlanFiles files;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
@ -49,9 +51,11 @@ public class TabCompleteCache implements SubSystem {
|
||||
|
||||
@Inject
|
||||
public TabCompleteCache(
|
||||
Processing processing,
|
||||
PlanFiles files,
|
||||
DBSystem dbSystem
|
||||
) {
|
||||
this.processing = processing;
|
||||
this.files = files;
|
||||
this.dbSystem = dbSystem;
|
||||
playerIdentifiers = new ArrayList<>();
|
||||
@ -62,15 +66,17 @@ public class TabCompleteCache implements SubSystem {
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
refreshPlayerIdentifiers();
|
||||
refreshServerIdentifiers();
|
||||
refreshUserIdentifiers();
|
||||
refreshBackupFileNames();
|
||||
processing.submitNonCritical(() -> {
|
||||
refreshPlayerIdentifiers();
|
||||
refreshServerIdentifiers();
|
||||
refreshUserIdentifiers();
|
||||
refreshBackupFileNames();
|
||||
|
||||
Collections.sort(playerIdentifiers);
|
||||
Collections.sort(serverIdentifiers);
|
||||
Collections.sort(userIdentifiers);
|
||||
Collections.sort(backupFileNames);
|
||||
Collections.sort(playerIdentifiers);
|
||||
Collections.sort(serverIdentifiers);
|
||||
Collections.sort(userIdentifiers);
|
||||
Collections.sort(backupFileNames);
|
||||
});
|
||||
}
|
||||
|
||||
private void refreshServerIdentifiers() {
|
||||
|
@ -84,6 +84,7 @@ public class ServerServerInfo extends ServerInfo {
|
||||
logger.info(locale.getString(PluginLang.LOADING_SERVER_INFO));
|
||||
Optional<Server> loaded = fromFile.load(null);
|
||||
server = loaded.orElseGet(this::registerNew);
|
||||
logger.info(locale.getString(PluginLang.LOADED_SERVER_INFO, server.getUuid().toString()));
|
||||
processing.submitNonCritical(this::updateStorage);
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ public enum PluginLang implements Lang {
|
||||
DB_NOTIFY_SQLITE_WAL("plugin.generic.dbNotifySQLiteWAL", "Database Notify - SQLite No WAL", "SQLite WAL mode not supported on this server version, using default. This may or may not affect performance."),
|
||||
DB_MYSQL_LAUNCH_OPTIONS_FAIL("plugin.generic.dbFaultyLaunchOptions", "Database MySQL - Launch Options Error", "Launch Options were faulty, using default (${0})"),
|
||||
LOADING_SERVER_INFO("plugin.generic.loadingServerInfo", "ServerInfo - Loading", "Loading server identifying information"),
|
||||
LOADED_SERVER_INFO("plugin.generic.loadedServerInfo", "ServerInfo - Loaded", "Server identifier loaded: ${0}"),
|
||||
DB_SCHEMA_PATCH("plugin.generic.dbSchemaPatch", "Database Notify - Patch", "Database: Making sure schema is up to date.."),
|
||||
;
|
||||
|
||||
|
@ -243,8 +243,13 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
* Updates to latest schema.
|
||||
*/
|
||||
private void setupDatabase() {
|
||||
executeTransaction(new OperationCriticalTransaction() {
|
||||
@Override
|
||||
protected void performOperations() {
|
||||
logger.info(locale.getString(PluginLang.DB_SCHEMA_PATCH));
|
||||
}
|
||||
});
|
||||
executeTransaction(new CreateTablesTransaction());
|
||||
logger.info(locale.getString(PluginLang.DB_SCHEMA_PATCH));
|
||||
for (Patch patch : patches()) {
|
||||
executeTransaction(patch);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user