From 0e9608726e04642dbf1c5dab0bc42528fe909d90 Mon Sep 17 00:00:00 2001 From: Sfurti-yb Date: Tue, 11 Nov 2025 10:29:54 +0530 Subject: [PATCH 1/2] Changed getEpochSeconds to toEpochMilli because Lock table expects time in milliseconds. --- .../postgresql/yugabytedb/YugabyteDBExecutionTemplate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java b/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java index 140bfeb..d9cdb78 100644 --- a/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java +++ b/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java @@ -86,7 +86,7 @@ private long tryLock() { if (!tableEntries.containsKey(tableName)) { try { - String now = new Timestamp(Instant.now().getEpochSecond()).toString(); + String now = new Timestamp(Instant.now().toEpochMilli()).toString(); statement.executeUpdate("INSERT INTO " + YugabyteDBDatabase.LOCK_TABLE_NAME + " VALUES ('" + tableName + "', 0, '" + now + "')"); From 07cbe65a29b30f8a79016e88cd889cdf31362919 Mon Sep 17 00:00:00 2001 From: Sfurti-yb Date: Wed, 12 Nov 2025 18:39:15 +0530 Subject: [PATCH 2/2] Changed getEpochSecond to toEpochMilli when reading the values from the table --- .../postgresql/yugabytedb/YugabyteDBExecutionTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java b/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java index d9cdb78..b9ee04d 100644 --- a/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java +++ b/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/yugabytedb/YugabyteDBExecutionTemplate.java @@ -116,7 +116,7 @@ private long tryLock() { if (rs.next()) { lockIdRead = rs.getLong("lock_id"); Timestamp tsRead = rs.getTimestamp("ts"); - String current = new Timestamp(Instant.now().getEpochSecond()).toString(); + String current = new Timestamp(Instant.now().toEpochMilli()).toString(); long lockIdTtl = DEFAULT_LOCK_ID_TTL; String sysProp = System.getProperty(LOCK_ID_TTL_SYS_PROP_NAME); if (sysProp != null) { @@ -128,7 +128,7 @@ private long tryLock() { } } - if (lockIdRead == 0 || Instant.now().getEpochSecond() - tsRead.getTime() > lockIdTtl) { + if (lockIdRead == 0 || Instant.now().toEpochMilli() - tsRead.getTime() > lockIdTtl) { lockIdToBeReturned = random.nextLong(); if (lockIdRead == 0) { LOG.debug(Thread.currentThread().getName() + "> Setting lock_id = " + lockIdToBeReturned);