Repository navigation
Fix/tickerplant wdb #776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix/tickerplant wdb #776
Changes from all commits
fff7e21
1bc586d
d4c39f4
c26d52a
595d468
3041311
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,12 +5,19 @@ currlog:([tbl:`symbol$()]logname:`symbol$();handle:`int$()) | |||||||||||
|
|
||||||||||||
| // View of log file handles for faster lookups | ||||||||||||
| loghandles::exec tbl!handle from currlog | ||||||||||||
| // Re-establish the view above. A chained tickerplant which is not creating logs replaces it with a dictionary of | ||||||||||||
| // no-ops (see init); without this, switching that process to create its own logs opened them but wrote nothing | ||||||||||||
| restoreloghandles:{value "loghandles::exec tbl!handle from currlog"}; | ||||||||||||
|
|
||||||||||||
| \d .stplg | ||||||||||||
|
|
||||||||||||
| // Name of error log file | ||||||||||||
| errorlogname:@[value;`.stplg.errorlogname;`segmentederrorlogfile] | ||||||||||||
|
|
||||||||||||
| // Whether this process writes logs of its own: a tickerplant with createlogs on, or a chained tickerplant creating its | ||||||||||||
| // own (loggingmode create). init opens them; dayrollover and .z.exit close them only where init opened them | ||||||||||||
| haslogs:{(value `..createlogs) or .sctp.loggingmode=`create}; | ||||||||||||
|
|
||||||||||||
| // Create stp log directory | ||||||||||||
| // Log structure `:stplogs/date/tabname_time | ||||||||||||
| createdld:{[name;date] | ||||||||||||
|
|
@@ -184,18 +191,20 @@ endofdaydata:@[value;`.stplg.endofdaydata;{ {`proctype`procname`tables!(.proc.pr | |||||||||||
| // passes on eop messages to subscribers and rolls logs | ||||||||||||
| endofperiod:{[currentpd;nextpd;data] | ||||||||||||
| .lg.o[`endofperiod;"flushing remaining data to subscribers and clearing tables"]; | ||||||||||||
| .stpps.pubclear[.stplg.t]; | ||||||||||||
| // the published tables only: pubclear resets a table from the publish schemas, which have no entry for logmsg | ||||||||||||
| .stpps.pubclear[.stpps.t]; | ||||||||||||
| .lg.o[`endofperiod;"executing end of period for ",.Q.s1 `currentperiod`nextperiod!(currentpd;nextpd)]; | ||||||||||||
| .stpps.endp[currentpd;nextpd;data]; // sends endofperiod message to subscribers | ||||||||||||
| currperiod::nextpd; // increments current period | ||||||||||||
| nextperiod::nextpd+nextpd-currentpd; // and the next one: the SCTP rolls when its parent does | ||||||||||||
| if[.sctp.loggingmode=`create;periodrollover[data]] // logs only rolled if in create mode | ||||||||||||
| }; | ||||||||||||
|
|
||||||||||||
| // stp runs function to send out end of period messages and roll logs | ||||||||||||
| // eop log roll is stopped if eod is also going to be triggered (roll is not stopped in SCTP) | ||||||||||||
| stpeoperiod:{[currentpd;nextpd;data;rolllogs] | ||||||||||||
| .lg.o[`endofperiod;"flushing remaining data to subscribers and clearing tables"]; | ||||||||||||
| .stpps.pubclear[.stplg.t]; | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we double check these changes from .stplg.t to .stpps.t - double confirm the old one is wrong (these feels a bit like something that should've bitten us before now)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
TorQ/code/segmentedtickerplant/stplog.q Line 250 in e901a32
logmsg. .stpps.t is the list of published tables, and since #638 it leaves logmsg out (https://github.com/DataIntellectTech/TorQ/pull/638/changes#diff-da8abe6e04ad1dd510c60b90806a4e4c94d7ff7ea63c4622066a87cf7b866297R36). Before #638 the two lists were the same, so these three calls were right when they were written. They have been wrong ever since.
Lines 86 to 89 in e901a32
logmsg, and a dictionary of tables returns an empty copy of its first table for a key it does not have. So at every end of period and end of day the tickerplant's logmsg is replaced by an empty table with the columns of the first published table.
|
||||||||||||
| .stpps.pubclear[.stpps.t]; | ||||||||||||
| .lg.o[`stpeoperiod;"passing on endofperiod message to subscribers"]; | ||||||||||||
| .stpps.endp[currentpd;nextpd;data]; // sends endofperiod message to subscribers | ||||||||||||
| currperiod::nextperiod; // increments current period | ||||||||||||
|
|
@@ -215,7 +224,7 @@ periodrollover:{[data] | |||||||||||
| // common eod for STP and SCTP to send out eod messages and roll logs | ||||||||||||
| endofday:{[date;data] | ||||||||||||
| .lg.o[`endofday;"flushing remaining data to subscribers and clearing tables"]; | ||||||||||||
| .stpps.pubclear[.stplg.t]; | ||||||||||||
| .stpps.pubclear[.stpps.t]; | ||||||||||||
| .lg.o[`endofday;"executing end of day for ",.Q.s1 .eodtime.d]; | ||||||||||||
| .stpps.end[date;data]; // sends endofday message to subscribers | ||||||||||||
| dayrollover[data]; | ||||||||||||
|
|
@@ -227,9 +236,12 @@ dayrollover:{[data] | |||||||||||
| system"t 0";'"next roll is in the past"]; // timer off | ||||||||||||
| getnextendUTC[]; // grabs next end time | ||||||||||||
| .eodtime.d+:1; // increment current day | ||||||||||||
| .stpm.updmeta[multilog][`close;logtabs;(data`p)+.eodtime.dailyadj]; // update meta tables | ||||||||||||
| .stpm.metatable:0#.stpm.metatable; | ||||||||||||
| closelog each logtabs; // close current day logs | ||||||||||||
| // only a process with logs of its own has logs to close: a chained tickerplant in loggingmode none or parent has no | ||||||||||||
| // log directory (.stplg.dldir), and closing failed there before the process was reinitialised | ||||||||||||
| if[haslogs[]; | ||||||||||||
| .stpm.updmeta[multilog][`close;logtabs;(data`p)+.eodtime.dailyadj]; // update meta tables | ||||||||||||
| .stpm.metatable:0#.stpm.metatable; | ||||||||||||
| closelog each logtabs]; // close current day logs | ||||||||||||
| init[string .proc.procname]; // reinitialise process | ||||||||||||
| .lg.o[`dayrollover;"end of day complete, new value for date is ",.Q.s1 .eodtime.d]; | ||||||||||||
| } | ||||||||||||
|
|
@@ -258,7 +270,8 @@ init:{[dbname] | |||||||||||
| i::1; | ||||||||||||
| seqnum::0; | ||||||||||||
|
|
||||||||||||
| if[(value `..createlogs) or .sctp.loggingmode=`create; | ||||||||||||
| if[haslogs[]; | ||||||||||||
| if[.sctp.chainedtp;`.[`restoreloghandles][]]; | ||||||||||||
| createdld[dbname;.eodtime.d]; | ||||||||||||
| openlog[multilog;dldir;;.z.p+.eodtime.dailyadj]each logtabs; | ||||||||||||
| // If appropriate, roll error log | ||||||||||||
|
|
@@ -291,9 +304,9 @@ init:{[dbname] | |||||||||||
| .lg.o[`stpexit; "Complete!"] | ||||||||||||
| ]; | ||||||||||||
|
|
||||||||||||
| // exit before logs are touched if process is an sctp NOT in create mode | ||||||||||||
| if[.sctp.chainedtp and not .sctp.loggingmode=`create; :()]; | ||||||||||||
| // exit before logs are touched if the process has none (an sctp NOT in create mode, or an stp with createlogs off) | ||||||||||||
| if[not .stplg.haslogs[]; :()]; | ||||||||||||
| .lg.o[`stpexit;"Closing off log files"]; | ||||||||||||
| .stpm.updmeta[.stplg.multilog][`close;.stpps.t;.z.p]; | ||||||||||||
| .stplg.closelog each .stpps.t; | ||||||||||||
| .stpm.updmeta[.stplg.multilog][`close;.stplg.logtabs;.z.p]; | ||||||||||||
| .stplg.closelog each .stplg.logtabs; | ||||||||||||
| }] | ||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // Schema for this suite: the Starter Pack's three tables and the two _iex tables the checks expect, whatever the application's own schema file defines | ||
| quote:([]time:`timestamp$(); sym:`g#`symbol$(); bid:`float$(); ask:`float$(); bsize:`long$(); asize:`long$(); mode:`char$(); ex:`char$(); src:`symbol$()) | ||
| trade:([]time:`timestamp$(); sym:`g#`symbol$(); price:`float$(); size:`int$(); stop:`boolean$(); cond:`char$(); ex:`char$();side:`symbol$()) | ||
| packets:([] time:`timestamp$(); sym:`symbol$(); src:`symbol$(); dest:`symbol$(); srcport:`long$(); destport:`long$(); seq:`long$(); ack:`long$(); win:`long$(); tsval:`long$(); tsecr:`long$(); flags:(); protocol:`symbol$(); length:`long$(); len:`long$(); data:()) | ||
| quote_iex:([]time:`timestamp$(); sym:`g#`symbol$(); bid:`float$(); ask:`float$(); bsize:`long$(); asize:`long$(); mode:`char$(); ex:`char$(); srctime:`timestamp$()) | ||
| trade_iex:([]time:`timestamp$(); sym:`g#`symbol$(); price:`float$(); size:`int$(); stop:`boolean$(); cond:`char$(); ex:`char$(); srctime:`timestamp$()) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| host,port,proctype,procname,U,localtime,g,T,w,load,startwithall,extras,qcmd | ||
| localhost,{KDBBASEPORT}+100,discovery,discovery1,,1,0,,,${KDBCODE}/processes/discovery.q,1,,q | ||
| localhost,{KDBBASEPORT}+101,segmentedtickerplant,stp1,,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-schemafile ${TORQHOME}/database.q,q | ||
| localhost,{KDBBASEPORT}+101,segmentedtickerplant,stp1,,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-schemafile ${KDBTESTS}/schemas/database.q,q | ||
| localhost,{KDBBASEPORT}+103,rdb,rdb1,,1,1,180,,${KDBCODE}/processes/rdb.q,1,,q | ||
| localhost,{KDBBASEPORT}+104,hdb,hdb1,,1,1,180,,${TORQHOME}/hdb,1,,q | ||
| localhost,{KDBBASEPORT}+105,wdb,wdb1,,1,1,180,,${KDBCODE}/processes/wdb.q,1,,q | ||
| localhost,{KDBBASEPORT}+104,hdb,hdb1,,1,1,180,,${KDBTESTS}/schemas/temphdb,1,,q | ||
| localhost,{KDBBASEPORT}+105,wdb,wdb1,,1,1,180,,${KDBCODE}/processes/wdb.q,1,-.wdb.savedir ${KDBTESTS}/schemas/tempwdb/ -.wdb.hdbdir ${KDBTESTS}/schemas/temphdb/,q |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this run through value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already done in chainedrecovery testing: it sends that line to the sctp as a string before changing mode.
TorQ/tests/stp/chainedrecovery/tabperiod.csv
Line 12 in e901a32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably just use set instead of
::?`loghandles set exec tbl!handle from currlog
Better practice for setting globals and should get around it not setting within the function