mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-15 03:41:38 +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.delivery.domain.auth.User;
|
||||||
import com.djrapitops.plan.identification.Server;
|
import com.djrapitops.plan.identification.Server;
|
||||||
import com.djrapitops.plan.identification.ServerUUID;
|
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.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||||
import com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries;
|
import com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries;
|
||||||
@ -39,6 +40,7 @@ import java.util.stream.Collectors;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class TabCompleteCache implements SubSystem {
|
public class TabCompleteCache implements SubSystem {
|
||||||
|
|
||||||
|
private final Processing processing;
|
||||||
private final PlanFiles files;
|
private final PlanFiles files;
|
||||||
private final DBSystem dbSystem;
|
private final DBSystem dbSystem;
|
||||||
|
|
||||||
@ -49,9 +51,11 @@ public class TabCompleteCache implements SubSystem {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TabCompleteCache(
|
public TabCompleteCache(
|
||||||
|
Processing processing,
|
||||||
PlanFiles files,
|
PlanFiles files,
|
||||||
DBSystem dbSystem
|
DBSystem dbSystem
|
||||||
) {
|
) {
|
||||||
|
this.processing = processing;
|
||||||
this.files = files;
|
this.files = files;
|
||||||
this.dbSystem = dbSystem;
|
this.dbSystem = dbSystem;
|
||||||
playerIdentifiers = new ArrayList<>();
|
playerIdentifiers = new ArrayList<>();
|
||||||
@ -62,15 +66,17 @@ public class TabCompleteCache implements SubSystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
refreshPlayerIdentifiers();
|
processing.submitNonCritical(() -> {
|
||||||
refreshServerIdentifiers();
|
refreshPlayerIdentifiers();
|
||||||
refreshUserIdentifiers();
|
refreshServerIdentifiers();
|
||||||
refreshBackupFileNames();
|
refreshUserIdentifiers();
|
||||||
|
refreshBackupFileNames();
|
||||||
|
|
||||||
Collections.sort(playerIdentifiers);
|
Collections.sort(playerIdentifiers);
|
||||||
Collections.sort(serverIdentifiers);
|
Collections.sort(serverIdentifiers);
|
||||||
Collections.sort(userIdentifiers);
|
Collections.sort(userIdentifiers);
|
||||||
Collections.sort(backupFileNames);
|
Collections.sort(backupFileNames);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshServerIdentifiers() {
|
private void refreshServerIdentifiers() {
|
||||||
|
@ -84,6 +84,7 @@ public class ServerServerInfo extends ServerInfo {
|
|||||||
logger.info(locale.getString(PluginLang.LOADING_SERVER_INFO));
|
logger.info(locale.getString(PluginLang.LOADING_SERVER_INFO));
|
||||||
Optional<Server> loaded = fromFile.load(null);
|
Optional<Server> loaded = fromFile.load(null);
|
||||||
server = loaded.orElseGet(this::registerNew);
|
server = loaded.orElseGet(this::registerNew);
|
||||||
|
logger.info(locale.getString(PluginLang.LOADED_SERVER_INFO, server.getUuid().toString()));
|
||||||
processing.submitNonCritical(this::updateStorage);
|
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_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})"),
|
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"),
|
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.."),
|
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.
|
* Updates to latest schema.
|
||||||
*/
|
*/
|
||||||
private void setupDatabase() {
|
private void setupDatabase() {
|
||||||
|
executeTransaction(new OperationCriticalTransaction() {
|
||||||
|
@Override
|
||||||
|
protected void performOperations() {
|
||||||
|
logger.info(locale.getString(PluginLang.DB_SCHEMA_PATCH));
|
||||||
|
}
|
||||||
|
});
|
||||||
executeTransaction(new CreateTablesTransaction());
|
executeTransaction(new CreateTablesTransaction());
|
||||||
logger.info(locale.getString(PluginLang.DB_SCHEMA_PATCH));
|
|
||||||
for (Patch patch : patches()) {
|
for (Patch patch : patches()) {
|
||||||
executeTransaction(patch);
|
executeTransaction(patch);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user