umustafi commented on code in PR #3790:
URL: https://github.com/apache/gobblin/pull/3790#discussion_r1343168089


##########
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/MysqlMultiActiveLeaseArbiter.java:
##########
@@ -104,32 +116,50 @@ protected interface CheckedFunction<T, R> {
       + "VALUES(1, ?, ?) ON DUPLICATE KEY UPDATE epsilon=VALUES(epsilon), 
linger=VALUES(linger)";
   protected static final String WHERE_CLAUSE_TO_MATCH_KEY = "WHERE 
flow_group=? AND flow_name=? AND flow_action=?";
   protected static final String WHERE_CLAUSE_TO_MATCH_ROW = 
WHERE_CLAUSE_TO_MATCH_KEY
-      + " AND event_timestamp=? AND lease_acquisition_timestamp=?";
-  protected static final String SELECT_AFTER_INSERT_STATEMENT = "SELECT 
event_timestamp, lease_acquisition_timestamp, "
-    + "linger FROM %s, %s " + WHERE_CLAUSE_TO_MATCH_KEY;
+      + " AND event_timestamp=CONVERT_TZ(?, '+00:00', @@session.time_zone)"
+      + " AND lease_acquisition_timestamp=CONVERT_TZ(?, '+00:00', 
@@session.time_zone)";

Review Comment:
   From the documentation, the timestamp stored is in UTC but upon retrieval/or 
interpreting timestamps provided it automatically converts it to the current 
time zone (determined by the server's time). On our side we are utilizing all 
UTC timestamps so I convert it to session timezone as MySQL will interpret it 
as session timezone. I *think* using `UTC_TIMESTAMP` as the default won't 
change that so internally I am using session time zone with `CURRENT_TIMESTAMP` 
. I tried using `UTC_TIMESTAMP(3)` before and got a syntax error below. 
Debugging the timezone issues on the unit tests is what took the majority of 
time in this change and this configuration with the unit tests is what I could 
get to work and seem like it's using the same timezone everywhere. 
   
   `Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL 
syntax; check the manual that corresponds to your MySQL server version for the 
right syntax to use near 'UTC_TIMESTAMP(3), lease_acquisition_timestamp 
TIMESTAMP(3) NULL DEFAULT UTC_TIME' at line 1`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to