diff --git a/README.md b/README.md index 161eb6b4..97110dc2 100644 --- a/README.md +++ b/README.md @@ -196,8 +196,10 @@ How often the scheduler checks the database for due executions. Default `10s`.= 8) { LOG.info("Using MySQL jdbc-overrides version 8 and later. (v {})", dbVersion); - detectedCustomization = new MySQL8JdbcCustomization(true); + detectedCustomization = new MySQL8JdbcCustomization(persistTimestampInUTC); } else { LOG.info("Using MySQL jdbc-overrides for version older than 8. (v {})", dbVersion); - detectedCustomization = new MySQLJdbcCustomization(true); + detectedCustomization = new MySQLJdbcCustomization(persistTimestampInUTC); } } else { if (persistTimestampInUTC) { @@ -74,8 +81,7 @@ public AutodetectJdbcCustomization(DataSource dataSource, boolean persistTimesta "No database-specific jdbc-overrides applied. Behavior overridden to always store " + "timestamps in zone UTC"); } else { - Logger silencableLogger = LoggerFactory.getLogger(LOG.getName() + ".utc_warning"); - silencableLogger.warn( + SILENCABLE_LOG.warn( "No database-specific jdbc-overrides applied. Assuming time-related columns " + "to be of type compatibe with 'TIMESTAMP WITH TIME ZONE', i.e. zone is persisted." + " If not, consider overriding to always UTC via '.alwaysPersistTimestampInUTC()'."); @@ -151,4 +157,18 @@ public String createSelectDueQuery(String tableName, int limit, String andCondit public String getName() { return jdbcCustomization.getName(); } + + private void logWarningIfNotUTC(String database, boolean persistTimestampInUTC) { + if (!persistTimestampInUTC) { + SILENCABLE_LOG.warn( + "{}-schema does not support persistent timezones. " + + "It is recommended to store time in UTC to avoid issues with for example DST. " + + "For first time users, use setting 'alwaysPersistTimestampInUtc' to achieve this. " + + "Users upgrading from a version prior to v14.0.0 can either silence this logger, " + + "or perform a controlled upgrade to UTC timestamps. All old instances " + + "of the scheduler must be stopped and timestamps migrated to UTC before starting " + + "again, using 'alwaysPersistTimestampInUtc=true'.", + database); + } + } } diff --git a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MariaDBJdbcCustomization.java b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MariaDBJdbcCustomization.java index c1d2e11c..ce82a9d0 100644 --- a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MariaDBJdbcCustomization.java +++ b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MariaDBJdbcCustomization.java @@ -23,12 +23,6 @@ public class MariaDBJdbcCustomization extends DefaultJdbcCustomization { public MariaDBJdbcCustomization(boolean persistTimestampInUTC) { super(persistTimestampInUTC); - if (!persistTimestampInUTC) { - LOG.warn( - "{} does not support persistent timezones. " - + "It is recommended to store time in UTC to avoid issues with for example DST", - getClass().getName()); - } } @Override diff --git a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MySQL8JdbcCustomization.java b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MySQL8JdbcCustomization.java index f964bf11..acdebb1a 100644 --- a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MySQL8JdbcCustomization.java +++ b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MySQL8JdbcCustomization.java @@ -23,12 +23,6 @@ public class MySQL8JdbcCustomization extends DefaultJdbcCustomization { public MySQL8JdbcCustomization(boolean persistTimestampInUTC) { super(persistTimestampInUTC); - if (!persistTimestampInUTC) { - LOG.warn( - "{} does not support persistent timezones. " - + "It is recommended to store time in UTC to avoid issues with for example DST", - getClass().getName()); - } } @Override diff --git a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MySQLJdbcCustomization.java b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MySQLJdbcCustomization.java index 32ade6ca..54648589 100644 --- a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MySQLJdbcCustomization.java +++ b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/MySQLJdbcCustomization.java @@ -21,12 +21,6 @@ public class MySQLJdbcCustomization extends DefaultJdbcCustomization { public MySQLJdbcCustomization(boolean persistTimestampInUTC) { super(persistTimestampInUTC); - if (!persistTimestampInUTC) { - LOG.warn( - "{} does not support persistent timezones. " - + "It is recommended to store time in UTC to avoid issues with for example DST", - getClass().getName()); - } } @Override diff --git a/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/SchedulerTest.java b/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/SchedulerTest.java index d2197d41..bdedd0de 100644 --- a/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/SchedulerTest.java +++ b/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/SchedulerTest.java @@ -39,6 +39,7 @@ public class SchedulerTest { @RegisterExtension public EmbeddedPostgresqlExtension postgres = new EmbeddedPostgresqlExtension(); + // @RegisterExtension // public ChangeLogLevelsExtension changeLogLevels = new ChangeLogLevelsExtension( // new ChangeLogLevelsExtension.LogLevelOverride("com.github.kagkarlsson.scheduler", diff --git a/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/compatibility/PostgresqlCompatibilityTest.java b/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/compatibility/PostgresqlCompatibilityTest.java index cc92eaea..841197af 100644 --- a/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/compatibility/PostgresqlCompatibilityTest.java +++ b/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/compatibility/PostgresqlCompatibilityTest.java @@ -11,6 +11,7 @@ public class PostgresqlCompatibilityTest extends CompatibilityTest { @RegisterExtension public EmbeddedPostgresqlExtension postgres = new EmbeddedPostgresqlExtension(); + // Enable if test gets flaky! // @RegisterExtension // public ChangeLogLevelsExtension changeLogLevels = new ChangeLogLevelsExtension( diff --git a/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/functional/ExecutorPoolTest.java b/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/functional/ExecutorPoolTest.java index 9f0015c3..2b8ef86e 100644 --- a/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/functional/ExecutorPoolTest.java +++ b/db-scheduler/src/test/java/com/github/kagkarlsson/scheduler/functional/ExecutorPoolTest.java @@ -35,6 +35,7 @@ public class ExecutorPoolTest { public EmbeddedPostgresqlExtension postgres = new EmbeddedPostgresqlExtension(); @RegisterExtension public StopSchedulerExtension stopScheduler = new StopSchedulerExtension(); + // Enable if test gets flaky! // @RegisterExtension // public ChangeLogLevelsExtension changeLogLevels = new ChangeLogLevelsExtension( diff --git a/pom.xml b/pom.xml index 03021f10..40d7bc88 100644 --- a/pom.xml +++ b/pom.xml @@ -281,7 +281,7 @@ com.diffplug.spotless spotless-maven-plugin - 2.36.0 + 2.43.0 @@ -289,7 +289,7 @@ src/test/java/**/*.java - 1.16.0 + 1.17.0