Skip to content

Commit b882e10

Browse files
#672 make sort process call initmissingtables and notifyidbs instead … (#681)
* #672 make sort process call initmissingtables and notifyidbs instead of wdb * change initmissingtables to work with new set up * #672 clean up cpde and add some comments * #672 move idbreload to endofdaysort * #672 change the way initmissingtables works * #672 make use of wdbtypes for sort procs to connect to * #672 remove unnecessary whitespace * #672 make the initmissingtables command get sent to all wdbs --------- Co-authored-by: [email protected] <[email protected]>
1 parent a4aff2e commit b882e10

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

code/processes/wdb.q

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ tpcheckcycles:@[value;`tpcheckcycles;0W]; /-num
5454
sorttypes:@[value;`sorttypes;`sort]; /-list of sort types to look for upon a sort
5555
sortworkertypes:@[value;`sortworkertypes;`sortworker]; /-list of sort types to look for upon a sort being called with worker process
5656

57+
wdbtypes:@[value;`wdbtypes;`wdb]; /-list of wdb types for sort processes to look for on initmissingtables
58+
5759
subtabs:@[value;`subtabs;`]; /-list of tables to subscribe for
5860
subsyms:@[value;`subsyms;`]; /-list of syms to subscription to
5961
upd:@[value;`upd;{insert}]; /-value of the upd function
@@ -206,12 +208,6 @@ endofday:{[pt;processdata]
206208
if[.finspace.enabled;.finspace.notifyhdb[;changeset] each .finspace.hdbclusters];
207209
currentpartition::pt+1;
208210
/- in case of default/partbyenum writedown mode we want to initialise the new partition with all the table schemas
209-
/- then notify idb processes of the new db
210-
if[writedownmode in `partbyenum`default;
211-
.lg.o[`eod;"initialising wdbhdb for partition: ",string[currentpartition]];
212-
initmissingtables[];
213-
.lg.o[`eod;"notifying idbs for newly created partition"];
214-
notifyidbs[`.idb.rollover;currentpartition]];
215211
.lg.o[`eod;"end of day is now complete"];
216212
if[.finspace.enabled;.os.hdeldir[getenv[`KDBSCRATCH];0b]];
217213
};
@@ -424,6 +420,8 @@ endofdaysort:{[dir;pt;tablist;writedownmode;mergelimits;hdbsettings;mergemethod]
424420
endofdaymerge[dir;pt;tablist;mergelimits;hdbsettings;mergemethod;writedownmode];
425421
endofdaysortdate[dir;pt;key tablist;hdbsettings]
426422
];
423+
/- run steps to rollover idb
424+
idbreload[currentpartition+1];
427425
/- reset compression level (.z.zd)
428426
resetcompression[16 0 0]
429427
};
@@ -527,20 +525,21 @@ fixpartition:{[subto]
527525

528526
/- for writedown modes partbyenum/default we make sure that partition 0/currentpartition has all the tables.
529527
/- In that case we can use .Q.chk later to fill the db making it useable for intraday processes
530-
initmissingtables:{[]
531-
.lg.o[`fixpartition;"Adding missing tables(empty) to partition ",string currentpartition];
532-
inittable each tablelist[];
533-
filldb[];
528+
/- pt - date; partition for which the function should initialise
529+
initmissingtables:{[pt]
530+
.lg.o[`fixpartition;"Adding missing tables(empty) to partition ",string pt];
531+
inittable[;pt] each tablelist[];
532+
filldb[pt];
534533
}
535534

536-
filldb:{[]
535+
filldb:{[pt]
537536
/- for all enumerated partitions we want to make sure that all tables are present
538-
.Q.chk[.Q.par[hsym savedir; currentpartition; `]];
537+
.Q.chk[.Q.par[hsym savedir; pt; `]];
539538
}
540539

541540
/- initialises table t in db with its schema in part
542-
inittable:{[t]
543-
tabledir:` sv $[writedownmode~`partbyenum; .Q.par[.Q.dd[hsym savedir;currentpartition];0;t]; .Q.par[hsym savedir;currentpartition;t]],`;
541+
inittable:{[t;pt]
542+
tabledir:` sv $[writedownmode~`partbyenum; .Q.par[.Q.dd[hsym savedir;pt];0;t]; .Q.par[hsym savedir;pt;t]],`;
544543
if[() ~ key tabledir;tabledir set .Q.en[hsym hdbdir;0#value t]];
545544
}
546545

@@ -594,6 +593,19 @@ getsortparams:{[]
594593
];
595594
};
596595

596+
/- Function to trigger idb reload steps, The initmissingtables function needs to be ran on wdb process, however this function can be ran on the sort processes
597+
/- If the function is ran on sort process send initmissingtables command to wdbs
598+
idbreload:{[pt]
599+
.lg.o[`idb;"starting idb reload"];
600+
if[writedownmode in `partbyenum`default;
601+
.lg.o[`eod;"initialising wdbhdb for partition: ",string[pt]];
602+
$[.proc.proctype~`sort;{[pt]ws:exec w from .servers.getservers[`proctype;wdbtypes;()!();1b;0b];{[ws;pt]ws(`.wdb.initmissingtables;[pt])}[;pt] each ws}[pt];initmissingtables[pt]];
603+
.lg.o[`eod;"notifying idbs for newly created partition"];
604+
notifyidbs[`.idb.rollover;pt]
605+
];
606+
.lg.o[`idb;"idb reload complete"];
607+
};;
608+
597609
\d .
598610

599611
/- get the sort attributes for each table

code/wdb/origstartup.q

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ startup:{[]
1515
];
1616
subscribe[];
1717
/- add missing tables to partitions in case an IDB process wants to connect. Only applicable for partbyenum writedown mode
18-
if[.wdb.writedownmode in `default`partbyenum;initmissingtables[]];
18+
if[.wdb.writedownmode in `default`partbyenum;initmissingtables[currentpartition]];
1919
];
2020
@[`.; `upd; :; .wdb.upd];
21-
}
21+
}

config/settings/sort.q

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ignorelist:`heartbeat`logmsg // list of tables to ignore
55
hdbtypes:`hdb // list of hdb types to look for and call in hdb reload
66
rdbtypes:`rdb // list of rdb types to look for and call in rdb reload
77
tickerplanttypes:`tickerplant // list of tickerplant types to try and make a connection to
8+
wdbtypes:`wdb // list of wdb types to look for and call in wdb init tables
89
subtabs:` // list of tables to subscribe for (` for all)
910
subsyms:` // list of syms to subscribe for (` for all)
1011
savedir:hsym`$getenv[`TORQHOME],"/wdbhdb" // location to save wdb data
@@ -46,5 +47,5 @@ eodwaittime:0D00:00:10.000 // time to wait for async calls to compl
4647

4748
// Server connection details
4849
\d .servers
49-
CONNECTIONS:`hdb`tickerplant`rdb`gateway // list of connections to make at start up
50+
CONNECTIONS:`wdb`hdb`tickerplant`rdb`gateway // list of connections to make at start up
5051
STARTUP:1b // create connections

config/settings/wdb.q

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ignorelist:`heartbeat`logmsg
66
hdbtypes:`hdb // list of hdb types to look for and call in hdb reload
77
rdbtypes:`rdb // list of rdb types to look for and call in rdb reload
88
idbtypes:`idb // list of idb types to look for and call in rdb reload
9+
wdbtypes:() // wdb does not need to connect to itself
910
gatewaytypes:`gateway // list of gateway types to inform at reload
1011
tickerplanttypes:`segmentedtickerplant // list of tickerplant types to try and make a connection to
1112
subtabs:` // list of tables to subscribe for (` for all)

0 commit comments

Comments
 (0)