Made transaction wait delay configurable

This commit is contained in:
Rsl1122 2019-02-28 12:54:31 +02:00
parent b9ec70619a
commit 233a930c9c
5 changed files with 19 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import com.djrapitops.plan.db.access.transactions.init.OperationCriticalTransact
import com.djrapitops.plan.db.patches.*; import com.djrapitops.plan.db.patches.*;
import com.djrapitops.plan.system.locale.Locale; import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.settings.config.PlanConfig; import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.settings.paths.TimeSettings;
import com.djrapitops.plan.utilities.java.ThrowableUtils; import com.djrapitops.plan.utilities.java.ThrowableUtils;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.logging.L; import com.djrapitops.plugin.logging.L;
@ -112,8 +113,14 @@ public abstract class SQLDB extends AbstractDatabase {
} }
transactionExecutor.shutdown(); transactionExecutor.shutdown();
try { try {
if (!transactionExecutor.awaitTermination(20L, TimeUnit.SECONDS)) { Long waitMs = config.get(TimeSettings.DB_TRANSACTION_FINISH_WAIT_DELAY);
return transactionExecutor.shutdownNow(); if (!transactionExecutor.awaitTermination(waitMs, TimeUnit.MILLISECONDS)) {
List<Runnable> unfinished = transactionExecutor.shutdownNow();
int unfinishedCount = unfinished.size();
if (unfinishedCount > 0) {
logger.warn(unfinishedCount + " unfinished database transactions were not executed.");
}
return unfinished;
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();

View File

@ -148,4 +148,9 @@ public abstract class Transaction {
protected UUID getServerUUID() { protected UUID getServerUUID() {
return db.getServerUUIDSupplier().get(); return db.getServerUUIDSupplier().get();
} }
@Override
public String toString() {
return getClass().getSimpleName() + (success ? " (finished)" : "");
}
} }

View File

@ -31,6 +31,7 @@ public class TimeSettings {
public static final Setting<Boolean> USE_SERVER_TIME = new BooleanSetting("Time.Use_server_timezone"); public static final Setting<Boolean> USE_SERVER_TIME = new BooleanSetting("Time.Use_server_timezone");
public static final Setting<Long> PING_SERVER_ENABLE_DELAY = new TimeSetting("Time.Delays.Ping_server_enable_delay"); public static final Setting<Long> PING_SERVER_ENABLE_DELAY = new TimeSetting("Time.Delays.Ping_server_enable_delay");
public static final Setting<Long> PING_PLAYER_LOGIN_DELAY = new TimeSetting("Time.Delays.Ping_player_join_delay"); public static final Setting<Long> PING_PLAYER_LOGIN_DELAY = new TimeSetting("Time.Delays.Ping_player_join_delay");
public static final Setting<Long> DB_TRANSACTION_FINISH_WAIT_DELAY = new TimeSetting("Time.Delays.Wait_for_DB_Transactions_on_disable");
public static final Setting<Long> AFK_THRESHOLD = new TimeSetting("Time.Thresholds.AFK_threshold"); public static final Setting<Long> AFK_THRESHOLD = new TimeSetting("Time.Thresholds.AFK_threshold");
public static final Setting<Integer> ACTIVE_LOGIN_THRESHOLD = new IntegerSetting("Time.Thresholds.Activity_index.Login_threshold", Setting::timeValidator); public static final Setting<Integer> ACTIVE_LOGIN_THRESHOLD = new IntegerSetting("Time.Thresholds.Activity_index.Login_threshold", Setting::timeValidator);
public static final Setting<Long> ACTIVE_PLAY_THRESHOLD = new TimeSetting("Time.Thresholds.Activity_index.Playtime_threshold"); public static final Setting<Long> ACTIVE_PLAY_THRESHOLD = new TimeSetting("Time.Thresholds.Activity_index.Playtime_threshold");

View File

@ -70,6 +70,8 @@ Time:
Unit: SECONDS Unit: SECONDS
Ping_player_join_delay: 30 Ping_player_join_delay: 30
Unit: SECONDS Unit: SECONDS
Wait_for_DB_Transactions_on_disable:
Unit: SECONDS
Thresholds: Thresholds:
# How long player needs to be idle until Plan considers them AFK # How long player needs to be idle until Plan considers them AFK
AFK_threshold: 3 AFK_threshold: 3

View File

@ -75,6 +75,8 @@ Time:
Unit: SECONDS Unit: SECONDS
Ping_player_join_delay: 30 Ping_player_join_delay: 30
Unit: SECONDS Unit: SECONDS
Wait_for_DB_Transactions_on_disable: 20
Unit: SECONDS
Thresholds: Thresholds:
# How long player needs to be idle until Plan considers them AFK # How long player needs to be idle until Plan considers them AFK
AFK_threshold: 3 AFK_threshold: 3