Skip to content

Commit 4d04cbe

Browse files
mpeypersvc-squareup-copybara
authored andcommitted
Small fix to help prevent falsely reporting clock skew when the
DB is under heavy load. There is a semantic difference between how `NOW()` and `SYSDATE()` work ([docs](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_sysdate)), mainly being that `NOW()` captures the time when the query begins execution and can be manipulated by some variables (generally for testing purposes) while `SYSDATE()` returns the time the function is executed (i.e. closer to when it is returned to the client) and cannot be manipulated. GitOrigin-RevId: 298fb59bc79e5f6b3fed96017bd2cdd2f7a6b279
1 parent 7ad70a9 commit 4d04cbe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

misk-hibernate/src/main/kotlin/misk/hibernate/HibernateHealthCheck.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal class HibernateHealthCheck(
2929
val databaseInstant = try {
3030
val sessionFactory = sessionFactoryService.get().sessionFactory
3131
sessionFactory.openSession().use { session ->
32-
session.createNativeQuery("SELECT NOW()").uniqueResult() as Timestamp
32+
session.createNativeQuery("SELECT SYSDATE()").uniqueResult() as Timestamp
3333
}.toInstant()
3434
} catch (e: Exception) {
3535
logger.error(e) { "error performing hibernate health check" }

0 commit comments

Comments
 (0)