From b7054488c1668bca9e6c05d86b44b38a335955ab Mon Sep 17 00:00:00 2001 From: Daniel Hunter Date: Fri, 4 Dec 2026 11:45:17 +0000 Subject: [PATCH 1/2] Fix EOD called twice at DST change in eodtime.getroll getroll converted the roll time to UTC using the timezone offset at the time of calculation, not at the time the roll runs. When clocks changed between the two, the next roll was stored an hour out, so EOD fired early and then again (e.g. America/New_York, autumn: 21:10 UTC stored instead of 22:10 UTC). - getroll: calculate the next roll in the roll timezone, then convert to UTC with .tz.gl so the offset at the roll time is used --- code/common/eodtime.q | 14 +++++++++++--- tests/stp/chainedeod/eodroutine.csv | 2 +- tests/stp/chainedeod/process.csv | 8 ++++---- tests/stp/chainedeod/run.sh | 1 + 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/code/common/eodtime.q b/code/common/eodtime.q index 44bef274e..9cb1f1bda 100644 --- a/code/common/eodtime.q +++ b/code/common/eodtime.q @@ -17,11 +17,19 @@ adjtime:{[p] :exec adjustment from .tz.t asof `timezoneID`gmtDateTime!(.eodtime.rolltimezone;.z.p); }; +// function to get time (in UTC) of next roll after UTC timestamp, p +// getroll:{[p] +// z:rolltimeoffset-adjtime[p]; // convert rolltimeoffset from rolltimezone to UTC +// z:`timespan$(mod) . "j"$z, 1D; // force time adjust to be between 0D and 1D +// ("d"$p) + $[z <= p;z+1D;z] // if past time already today, make it tomorrow +// }; // function to get time (in UTC) of next roll after UTC timestamp, p getroll:{[p] - z:rolltimeoffset-adjtime[p]; // convert rolltimeoffset from rolltimezone to UTC - z:`timespan$(mod) . "j"$z, 1D; // force time adjust to be between 0D and 1D - ("d"$p) + $[z <= p;z+1D;z] // if past time already today, make it tomorrow + rolltod:`timespan$(mod) . "j"$rolltimeoffset,1D; // roll time of day, in rolltimezone + localp:.tz.lg[rolltimezone;p]; // p in rolltimezone + localroll:("d"$localp)+rolltod; // today's roll, local + localroll:$[localroll<=localp;localroll+1D;localroll]; // if already passed, use tomorrow + .tz.gl[rolltimezone;localroll] // local to UTC, using the offset at the roll time }; // function to determine the date (in rolltimezone) from UTC timestamp, p diff --git a/tests/stp/chainedeod/eodroutine.csv b/tests/stp/chainedeod/eodroutine.csv index 488042c8a..b480a1da1 100644 --- a/tests/stp/chainedeod/eodroutine.csv +++ b/tests/stp/chainedeod/eodroutine.csv @@ -17,7 +17,7 @@ true,0,0,q,1=counttplogs[`stptest1],1,,"Should be 1 log directory for STP" true,0,0,q,1=counttplogs[`sctptest1],1,,"Should be 1 log directory for SCTP" run,0,0,q,now:.z.p,1,,"Get current time" run,0,0,q,data:stpHandle".stplg.endofdaydata[]",1,,"get data" -run,0,0,q,"stpHandle(`.stplg.stpeod;.eodtime.d;data,(enlist `p)!enlist now)",1,,"Run EoD function on STP" +run,0,0,q,"stpHandle(`.stplg.endofday;.eodtime.d;data,(enlist `p)!enlist now)",1,,"Run EoD function on STP" true,0,0,q,all 0 = sctpHandle"count each `. .stpps.t",1,,"Check tables have been flushed" run,0,0,q,meta2:get .Q.dd[sctpDir1;`stpmeta],1,,"Get meta table from disk" run,0,0,q,stpEod2:stpHandle".eodtime.d",1,,"Get new date on STP" diff --git a/tests/stp/chainedeod/process.csv b/tests/stp/chainedeod/process.csv index 35146e9a2..03ad7fbc0 100644 --- a/tests/stp/chainedeod/process.csv +++ b/tests/stp/chainedeod/process.csv @@ -1,5 +1,5 @@ host,port,proctype,procname,U,localtime,g,T,w,load,startwithall,extras,qcmd -localhost,{KDBBASEPORT}+100,discovery,discovery1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/discovery.q,1,,q -localhost,{KDBBASEPORT}+101,segmentedtickerplant,stptest1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-schemafile ${TORQHOME}/database.q,q -localhost,{KDBBASEPORT}+102,segmentedchainedtickerplant,sctptest1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-parentproctype segmentedtickerplant -.sctp.loggingmode create -.sctp.tickerplantname stptest1,q -localhost,{KDBBASEPORT}+103,rdb,rdb1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,-.rdb.tickerplanttypes segmentedchainedtickerplant,q +localhost,{KDBBASEPORT}+100,discovery,discovery1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/discovery.q,1,,q +localhost,{KDBBASEPORT}+101,segmentedtickerplant,stptest1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-schemafile ${TORQAPPHOME}/database.q,q +localhost,{KDBBASEPORT}+102,segmentedchainedtickerplant,sctptest1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-parentproctype segmentedtickerplant -.sctp.loggingmode create -.sctp.tickerplantname stptest1,q +localhost,{KDBBASEPORT}+103,rdb,rdb1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,-.rdb.tickerplanttypes segmentedchainedtickerplant,q diff --git a/tests/stp/chainedeod/run.sh b/tests/stp/chainedeod/run.sh index 1b1001617..11fe2b224 100755 --- a/tests/stp/chainedeod/run.sh +++ b/tests/stp/chainedeod/run.sh @@ -16,6 +16,7 @@ ${TORQHOME}/torq.sh start discovery1 stptest1 sctptest1 rdb1 -csv ${testpath}/pr -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ -results ${KDBTESTS}/stp/results/ \ -procfile ${testpath}/process.csv \ + -debug \ -runtime $run \ $debug $stop $quiet From 3046165798a76aaf8cc70b02dc31fb02baf9a89b Mon Sep 17 00:00:00 2001 From: Daniel Hunter Date: Fri, 4 Dec 2026 13:43:20 +0000 Subject: [PATCH 2/2] removed previous code. Added fix for chainedeod unit test. --- code/common/eodtime.q | 6 ------ 1 file changed, 6 deletions(-) diff --git a/code/common/eodtime.q b/code/common/eodtime.q index 9cb1f1bda..b7d1fabf7 100644 --- a/code/common/eodtime.q +++ b/code/common/eodtime.q @@ -17,12 +17,6 @@ adjtime:{[p] :exec adjustment from .tz.t asof `timezoneID`gmtDateTime!(.eodtime.rolltimezone;.z.p); }; -// function to get time (in UTC) of next roll after UTC timestamp, p -// getroll:{[p] -// z:rolltimeoffset-adjtime[p]; // convert rolltimeoffset from rolltimezone to UTC -// z:`timespan$(mod) . "j"$z, 1D; // force time adjust to be between 0D and 1D -// ("d"$p) + $[z <= p;z+1D;z] // if past time already today, make it tomorrow -// }; // function to get time (in UTC) of next roll after UTC timestamp, p getroll:{[p] rolltod:`timespan$(mod) . "j"$rolltimeoffset,1D; // roll time of day, in rolltimezone