From 4cce8064c178c4787832ccb9ff820fcab4fb6c4e Mon Sep 17 00:00:00 2001 From: czaquaq Date: Thu, 23 Mar 2023 14:51:19 -0400 Subject: [PATCH 01/13] Added support for synchronization of the eod reload. --- code/hdb/hdbstandard.q | 5 ++++- code/processes/gateway.q | 4 ++++ code/processes/rdb.q | 4 ++++ config/settings/gateway.q | 2 ++ config/settings/hdb.q | 5 +++++ config/settings/rdb.q | 3 +++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index cb1f75dc7..31bff5550 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -1,7 +1,10 @@ // reload function reload:{ + .[`.hdb.reloadcalls;();+;1]; + .lg.o[`reload;string[.hdb.reloadcalls]," out of ",string[.hdb.expectedreloadcalls]," calls received"]; + if[.hdb.reloadcalls<.hdb.expectedreloadcalls;:(::)]; .lg.o[`reload;"reloading HDB"]; - system"l ."} + system"l .";.[`.hdb.reloadcalls;();:;0];} // Get the relevant HDB attributes .proc.getattributes:{`date`tables!(@[value;`date;`date$()];tables[])} diff --git a/code/processes/gateway.q b/code/processes/gateway.q index e0fbbd566..6a4257bd7 100644 --- a/code/processes/gateway.q +++ b/code/processes/gateway.q @@ -550,9 +550,13 @@ reloadstart:{ }; reloadend:{ + .[`.gw.reloadcalls;();+;1]; + .lg.o[`reload;string[.gw.reloadcalls]," out of ",string[.gw.expectedreloadcalls]," calls received"]; + if[.gw.reloadcalls<.gw.expectedreloadcalls;:(::)]; .lg.o[`reload;"reload end called"]; /- set eod variable to false .gw.seteod[0b]; + .[`.gw.reloadcalls;();:;0]; /- retry connections - get updated attributes from servers and refresh servers tables setattributes .' flip value flip select procname,proctype,@[;(`.proc.getattributes;`);()!()] each w from .servers.SERVERS where .dotz.liveh[w]; /- flush any async queries held during reload phase diff --git a/code/processes/rdb.q b/code/processes/rdb.q index 2fc9640ba..397826977 100644 --- a/code/processes/rdb.q +++ b/code/processes/rdb.q @@ -114,6 +114,9 @@ endofday:{[date;processdata] }; reload:{[date] + .[`.rdb.reloadcalls;();+;1]; + .lg.o[`reload;string[.rdb.reloadcalls]," out of ",string[.rdb.expectedreloadcalls]," calls received"]; + if[.rdb.reloadcalls<.rdb.expectedreloadcalls;:(::)]; .lg.o[`reload;"reload command has been called remotely"]; /-get all attributes from all tables before they are wiped /-get a list of pairs (tablename;columnname!attributes) @@ -131,6 +134,7 @@ reload:{[date] /-restore original timeout back to rdb restoretimeout[]; .lg.o[`reload;"Finished reloading RDB"]; + .[`.rdb.reloadcalls;();:;0]; }; /-drop date from rdbpartition diff --git a/config/settings/gateway.q b/config/settings/gateway.q index 820c6c9bc..26c92b57b 100644 --- a/config/settings/gateway.q +++ b/config/settings/gateway.q @@ -8,6 +8,8 @@ synccallsallowed:0b // whether synchronous calls are allowed querykeeptime:0D00:30 // the time to keep queries in the errorprefix:"error: " // the prefix for clients to look for in error strings clearinactivetime:0D01:00 // the time to keep inactive handle data +expectedreloadcalls:1 // the number of reloadend calls that need to be received before acting - + // same as the number of the WDB processes \d .kxdash enabled:0b // Functionality for parsing and handling kx dashboard queries - disabled by default diff --git a/config/settings/hdb.q b/config/settings/hdb.q index ecd6aeeee..0035eccb1 100644 --- a/config/settings/hdb.q +++ b/config/settings/hdb.q @@ -8,3 +8,8 @@ loadprocesscode:1b // whether to load the process specific code def CONNECTIONS:() // list of connections to make at start up STARTUP:1b // create connections +\d .hdb +expectedreloadcalls:1 // the number of reload calls that need to be received before acting - + // it could be the same as the number of the WDB processes, the number of the + // RDB processes, or the sum of both + diff --git a/config/settings/rdb.q b/config/settings/rdb.q index b69226394..c5b92e20d 100644 --- a/config/settings/rdb.q +++ b/config/settings/rdb.q @@ -22,6 +22,9 @@ gc:1b //if true .Q.gc will be called after sortcsv:hsym first .proc.getconfigfile["sort.csv"] //location of csv file reloadenabled:0b //if true, the RDB will not save when .u.end is called but //will clear it's data using reload function (called by the WDB) +expectedreloadcalls:1 + // the number of reload calls that need to be received before reloading - + // same as the number of the WDB processes, and has no effect if reloadenabled=0b parvaluesrc:`log //where to source the rdb partition value, can be log (from tp log file name), //tab (from the the first value in the time column of the table that is subscribed for) //anything else will return a null date which is will be filled by pardefault From e4728c0f450c5c8519b16e1459dcf579fc9b42f3 Mon Sep 17 00:00:00 2001 From: CReid Date: Mon, 24 Apr 2023 12:18:10 +0100 Subject: [PATCH 02/13] dynamically calculate number of expected reload calls in hdb, rdb and gateway --- code/hdb/hdbstandard.q | 3 +++ code/processes/gateway.q | 2 ++ code/processes/rdb.q | 2 ++ config/settings/gateway.q | 2 -- config/settings/hdb.q | 6 ------ config/settings/rdb.q | 4 +--- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index 31bff5550..c91391587 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -1,5 +1,8 @@ // reload function reload:{ + connectedProcs:{x(`.proc.proctype)} each .z.H; + .hdb.expectedreloadcalls:sum (`wdb=connectedProcs) +`rdb=connectedProcs; + // need to check this, may not need to add rdb in some cases .[`.hdb.reloadcalls;();+;1]; .lg.o[`reload;string[.hdb.reloadcalls]," out of ",string[.hdb.expectedreloadcalls]," calls received"]; if[.hdb.reloadcalls<.hdb.expectedreloadcalls;:(::)]; diff --git a/code/processes/gateway.q b/code/processes/gateway.q index 6a4257bd7..1350fa6a5 100644 --- a/code/processes/gateway.q +++ b/code/processes/gateway.q @@ -550,6 +550,8 @@ reloadstart:{ }; reloadend:{ + .gw.expectedreloadcalls:sum `wdb={x(`.proc.proctype)} each .z.H; + .[`.gw.reloadcalls;();+;1]; .lg.o[`reload;string[.gw.reloadcalls]," out of ",string[.gw.expectedreloadcalls]," calls received"]; if[.gw.reloadcalls<.gw.expectedreloadcalls;:(::)]; diff --git a/code/processes/rdb.q b/code/processes/rdb.q index 397826977..ccac8a0e6 100644 --- a/code/processes/rdb.q +++ b/code/processes/rdb.q @@ -114,6 +114,8 @@ endofday:{[date;processdata] }; reload:{[date] + .rdb.expectedreloadcalls:sum `wdb={x(`.proc.proctype)} each .z.H; + .[`.rdb.reloadcalls;();+;1]; .lg.o[`reload;string[.rdb.reloadcalls]," out of ",string[.rdb.expectedreloadcalls]," calls received"]; if[.rdb.reloadcalls<.rdb.expectedreloadcalls;:(::)]; diff --git a/config/settings/gateway.q b/config/settings/gateway.q index 26c92b57b..820c6c9bc 100644 --- a/config/settings/gateway.q +++ b/config/settings/gateway.q @@ -8,8 +8,6 @@ synccallsallowed:0b // whether synchronous calls are allowed querykeeptime:0D00:30 // the time to keep queries in the errorprefix:"error: " // the prefix for clients to look for in error strings clearinactivetime:0D01:00 // the time to keep inactive handle data -expectedreloadcalls:1 // the number of reloadend calls that need to be received before acting - - // same as the number of the WDB processes \d .kxdash enabled:0b // Functionality for parsing and handling kx dashboard queries - disabled by default diff --git a/config/settings/hdb.q b/config/settings/hdb.q index 0035eccb1..e89d9a53e 100644 --- a/config/settings/hdb.q +++ b/config/settings/hdb.q @@ -7,9 +7,3 @@ loadprocesscode:1b // whether to load the process specific code def \d .servers CONNECTIONS:() // list of connections to make at start up STARTUP:1b // create connections - -\d .hdb -expectedreloadcalls:1 // the number of reload calls that need to be received before acting - - // it could be the same as the number of the WDB processes, the number of the - // RDB processes, or the sum of both - diff --git a/config/settings/rdb.q b/config/settings/rdb.q index c5b92e20d..f1980915e 100644 --- a/config/settings/rdb.q +++ b/config/settings/rdb.q @@ -22,9 +22,7 @@ gc:1b //if true .Q.gc will be called after sortcsv:hsym first .proc.getconfigfile["sort.csv"] //location of csv file reloadenabled:0b //if true, the RDB will not save when .u.end is called but //will clear it's data using reload function (called by the WDB) -expectedreloadcalls:1 - // the number of reload calls that need to be received before reloading - - // same as the number of the WDB processes, and has no effect if reloadenabled=0b + parvaluesrc:`log //where to source the rdb partition value, can be log (from tp log file name), //tab (from the the first value in the time column of the table that is subscribed for) //anything else will return a null date which is will be filled by pardefault From c7f2c7e0de3cf82c6c7a9ca6d70dbe47807e8e31 Mon Sep 17 00:00:00 2001 From: CReid Date: Mon, 24 Apr 2023 17:26:37 +0100 Subject: [PATCH 03/13] remove unneeded comment --- code/hdb/hdbstandard.q | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index c91391587..04000c8f7 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -2,7 +2,7 @@ reload:{ connectedProcs:{x(`.proc.proctype)} each .z.H; .hdb.expectedreloadcalls:sum (`wdb=connectedProcs) +`rdb=connectedProcs; - // need to check this, may not need to add rdb in some cases + .[`.hdb.reloadcalls;();+;1]; .lg.o[`reload;string[.hdb.reloadcalls]," out of ",string[.hdb.expectedreloadcalls]," calls received"]; if[.hdb.reloadcalls<.hdb.expectedreloadcalls;:(::)]; From e827a5568cacb50f7f7003226da23a9bd40bff79 Mon Sep 17 00:00:00 2001 From: CReid Date: Wed, 26 Apr 2023 09:01:41 +0100 Subject: [PATCH 04/13] Fix to avoid block, no longer querying connected processes to get process type --- code/hdb/hdbstandard.q | 3 +-- code/processes/gateway.q | 2 +- code/processes/rdb.q | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index 04000c8f7..91a20ec7d 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -1,7 +1,6 @@ // reload function reload:{ - connectedProcs:{x(`.proc.proctype)} each .z.H; - .hdb.expectedreloadcalls:sum (`wdb=connectedProcs) +`rdb=connectedProcs; + .hdb.expectedreloadcalls:count select from .clients.clients where u in `wdb`rdb, not null w; .[`.hdb.reloadcalls;();+;1]; .lg.o[`reload;string[.hdb.reloadcalls]," out of ",string[.hdb.expectedreloadcalls]," calls received"]; diff --git a/code/processes/gateway.q b/code/processes/gateway.q index 1350fa6a5..3a1fa0056 100644 --- a/code/processes/gateway.q +++ b/code/processes/gateway.q @@ -550,7 +550,7 @@ reloadstart:{ }; reloadend:{ - .gw.expectedreloadcalls:sum `wdb={x(`.proc.proctype)} each .z.H; + .gw.expectedreloadcalls:;count select from .clients.clients where u in `wdb, not null w; .[`.gw.reloadcalls;();+;1]; .lg.o[`reload;string[.gw.reloadcalls]," out of ",string[.gw.expectedreloadcalls]," calls received"]; diff --git a/code/processes/rdb.q b/code/processes/rdb.q index ccac8a0e6..4ec99997e 100644 --- a/code/processes/rdb.q +++ b/code/processes/rdb.q @@ -114,7 +114,7 @@ endofday:{[date;processdata] }; reload:{[date] - .rdb.expectedreloadcalls:sum `wdb={x(`.proc.proctype)} each .z.H; + .rdb.expectedreloadcalls:count select from .clients.clients where u in `wdb, not null w; .[`.rdb.reloadcalls;();+;1]; .lg.o[`reload;string[.rdb.reloadcalls]," out of ",string[.rdb.expectedreloadcalls]," calls received"]; From ebce23d57c723931ab5c692d585b1d119be92d82 Mon Sep 17 00:00:00 2001 From: CReid Date: Wed, 3 May 2023 11:11:53 +0100 Subject: [PATCH 05/13] - reload calls tracked via dictionary mapping handles to boolean value - dictionary expectedreloadcalls updated by .z.po and .z.pc - .z.pc automatically triggers reload if wdb or rdb disconnects - handling added for user to bypass check if reload triggered manually --- code/hdb/hdbstandard.q | 24 +++++++++++++++++++----- code/processes/gateway.q | 21 ++++++++++++++++----- code/processes/rdb.q | 22 ++++++++++++++++------ 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index 91a20ec7d..244b959b1 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -1,12 +1,26 @@ // reload function reload:{ - .hdb.expectedreloadcalls:count select from .clients.clients where u in `wdb`rdb, not null w; - - .[`.hdb.reloadcalls;();+;1]; - .lg.o[`reload;string[.hdb.reloadcalls]," out of ",string[.hdb.expectedreloadcalls]," calls received"]; - if[.hdb.reloadcalls<.hdb.expectedreloadcalls;:(::)]; + + if[.z.w in key .hdb.reloadcalls; + .hdb.reloadcalls[.z.w]:1b; + .lg.o[`reload;"reload call received from handle ", string[.z.w], " reload calls pending from handles", raze ssr[", %x"; "%x";] each string key .hdb.reloadcalls]; + if[not all value .hdb.reloadcalls;:(::)]]; .lg.o[`reload;"reloading HDB"]; + {.hdb.reloadcalls[x]:0} each key .hdb.reloadcalls; system"l .";.[`.hdb.reloadcalls;();:;0];} // Get the relevant HDB attributes .proc.getattributes:{`date`tables!(@[value;`date;`date$()];tables[])} + +\d .hdb + +// dictionary of handles to reload +reloadcalls:()!(); + +// function to add handle to reloadcalls dictionary +po:{[h] if[.z.u in `wdb`rdb;reloadcalls[h]:0b]}; +.z.po:{[f;x] @[f;x;()];.hdb.po x} @[value;`.z.po;{{}}]; + +// function to remove handle from reloadcalls dictionary +pc:{[h] reloadcalls _: h; if[all value .hdb.reloadcalls;reload[]]}; +.z.pc:{[f;x] @[f;x;()];.hdb.pc x} @[value;`.z.pc;{{}}]; diff --git a/code/processes/gateway.q b/code/processes/gateway.q index 3a1fa0056..d4d6fdfa3 100644 --- a/code/processes/gateway.q +++ b/code/processes/gateway.q @@ -550,15 +550,15 @@ reloadstart:{ }; reloadend:{ - .gw.expectedreloadcalls:;count select from .clients.clients where u in `wdb, not null w; + if[.z.w in key .gw.reloadcalls; + .gw.reloadcalls[.z.w]:1b; + .lg.o[`reload;"reload call received from handle ", string[.z.w], " reload calls pending from handles", raze ssr[", %x"; "%x";] each string key .gw.reloadcalls]; + if[not all value .gw.reloadcalls;:(::)]]; - .[`.gw.reloadcalls;();+;1]; - .lg.o[`reload;string[.gw.reloadcalls]," out of ",string[.gw.expectedreloadcalls]," calls received"]; - if[.gw.reloadcalls<.gw.expectedreloadcalls;:(::)]; .lg.o[`reload;"reload end called"]; /- set eod variable to false .gw.seteod[0b]; - .[`.gw.reloadcalls;();:;0]; + {.gw.reloadcalls[x]:0} each key .gw.reloadcalls; /- retry connections - get updated attributes from servers and refresh servers tables setattributes .' flip value flip select procname,proctype,@[;(`.proc.getattributes;`);()!()] each w from .servers.SERVERS where .dotz.liveh[w]; /- flush any async queries held during reload phase @@ -643,4 +643,15 @@ neg[h](`.gw.asyncexecjpt;(`.q.system;"sleep 10");enlist[`servertype]!enlist`rdb` h(`.gw.syncexec;"`$last .z.x";enlist[`tables]!enlist enlist`logmsgXXX) h(`.gw.syncexec;"`$last .z.x";`tables`servertype!(enlist`data;`rdb`hdb)) +\d .gwreload +// dictionary of handles to reload +reloadcalls:()!(); + +// function to add handle to reloadcalls dictionary +po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]}; +.z.po:{[f;x] @[f;x;()];.gwreload.po x} @[value;`.z.po;{{}}]; + +// function to remove handle from reloadcalls dictionary +pc:{[h] reloadcalls _: h; if[all value .gwreload.reloadcalls;reload[]]}; +.z.pc:{[f;x] @[f;x;()];.gwreload.pc x} @[value;`.z.pc;{{}}]; diff --git a/code/processes/rdb.q b/code/processes/rdb.q index 4ec99997e..52f568f58 100644 --- a/code/processes/rdb.q +++ b/code/processes/rdb.q @@ -114,11 +114,10 @@ endofday:{[date;processdata] }; reload:{[date] - .rdb.expectedreloadcalls:count select from .clients.clients where u in `wdb, not null w; - - .[`.rdb.reloadcalls;();+;1]; - .lg.o[`reload;string[.rdb.reloadcalls]," out of ",string[.rdb.expectedreloadcalls]," calls received"]; - if[.rdb.reloadcalls<.rdb.expectedreloadcalls;:(::)]; + if[.z.w in key .rdb.reloadcalls; + .rdb.reloadcalls[.z.w]:1b; + .lg.o[`reload;"reload call received from handle ", string[.z.w], " reload calls pending from handles", raze ssr[", %x"; "%x";] each string key .rdb.reloadcalls]; + if[not all value .rdb.reloadcalls;:(::)]]; .lg.o[`reload;"reload command has been called remotely"]; /-get all attributes from all tables before they are wiped /-get a list of pairs (tablename;columnname!attributes) @@ -136,8 +135,19 @@ reload:{[date] /-restore original timeout back to rdb restoretimeout[]; .lg.o[`reload;"Finished reloading RDB"]; - .[`.rdb.reloadcalls;();:;0]; + {.rdb.reloadcalls[x]:0} each key .rdb.reloadcalls; }; + +// dictionary of handles to reload +reloadcalls:()!(); + +// function to add handle to reloadcalls dictionary +po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]}; +.z.po:{[f;x] @[f;x;()];.rdb.po x} @[value;`.z.po;{{}}]; + +// function to remove handle from reloadcalls dictionary +pc:{[h] reloadcalls _: h; if[all value .rdb.reloadcalls;reload[]]}; +.z.pc:{[f;x] @[f;x;()];.rdb.pc x} @[value;`.z.pc;{{}}]; /-drop date from rdbpartition rmdtfromgetpar:{[date] From f930bac139e1fbe7fb3db7dcc299078894ceb54e Mon Sep 17 00:00:00 2001 From: CReid Date: Fri, 5 May 2023 09:35:18 +0100 Subject: [PATCH 06/13] fixing issues brought up in code review --- code/hdb/hdbstandard.q | 6 +++--- code/processes/gateway.q | 8 ++++---- code/processes/rdb.q | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index 244b959b1..65bd4a7b1 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -3,10 +3,10 @@ reload:{ if[.z.w in key .hdb.reloadcalls; .hdb.reloadcalls[.z.w]:1b; - .lg.o[`reload;"reload call received from handle ", string[.z.w], " reload calls pending from handles", raze ssr[", %x"; "%x";] each string key .hdb.reloadcalls]; - if[not all value .hdb.reloadcalls;:(::)]]; + .lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .hdb.reloadcalls]; + if[not all .hdb.reloadcalls;:(::)]]; .lg.o[`reload;"reloading HDB"]; - {.hdb.reloadcalls[x]:0} each key .hdb.reloadcalls; + @[`.hdb.reloadcalls;key .hdb.reloadcalls;:;0b]; system"l .";.[`.hdb.reloadcalls;();:;0];} // Get the relevant HDB attributes diff --git a/code/processes/gateway.q b/code/processes/gateway.q index d4d6fdfa3..690f2bab0 100644 --- a/code/processes/gateway.q +++ b/code/processes/gateway.q @@ -552,13 +552,13 @@ reloadstart:{ reloadend:{ if[.z.w in key .gw.reloadcalls; .gw.reloadcalls[.z.w]:1b; - .lg.o[`reload;"reload call received from handle ", string[.z.w], " reload calls pending from handles", raze ssr[", %x"; "%x";] each string key .gw.reloadcalls]; - if[not all value .gw.reloadcalls;:(::)]]; + .lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .gw.reloadcalls]; + if[not all .gw.reloadcalls;:(::)]]; .lg.o[`reload;"reload end called"]; /- set eod variable to false .gw.seteod[0b]; - {.gw.reloadcalls[x]:0} each key .gw.reloadcalls; + @[`.gw.reloadcalls; key .gw.reloadcalls;:;0b]; /- retry connections - get updated attributes from servers and refresh servers tables setattributes .' flip value flip select procname,proctype,@[;(`.proc.getattributes;`);()!()] each w from .servers.SERVERS where .dotz.liveh[w]; /- flush any async queries held during reload phase @@ -653,5 +653,5 @@ po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]}; .z.po:{[f;x] @[f;x;()];.gwreload.po x} @[value;`.z.po;{{}}]; // function to remove handle from reloadcalls dictionary -pc:{[h] reloadcalls _: h; if[all value .gwreload.reloadcalls;reload[]]}; +pc:{[h] reloadcalls _: h; if[all .gwreload.reloadcalls;reload[]]}; .z.pc:{[f;x] @[f;x;()];.gwreload.pc x} @[value;`.z.pc;{{}}]; diff --git a/code/processes/rdb.q b/code/processes/rdb.q index 52f568f58..a560ae82e 100644 --- a/code/processes/rdb.q +++ b/code/processes/rdb.q @@ -116,8 +116,8 @@ endofday:{[date;processdata] reload:{[date] if[.z.w in key .rdb.reloadcalls; .rdb.reloadcalls[.z.w]:1b; - .lg.o[`reload;"reload call received from handle ", string[.z.w], " reload calls pending from handles", raze ssr[", %x"; "%x";] each string key .rdb.reloadcalls]; - if[not all value .rdb.reloadcalls;:(::)]]; + .lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .rdb.reloadcalls]; + if[not all .rdb.reloadcalls;:(::)]]; .lg.o[`reload;"reload command has been called remotely"]; /-get all attributes from all tables before they are wiped /-get a list of pairs (tablename;columnname!attributes) @@ -135,7 +135,7 @@ reload:{[date] /-restore original timeout back to rdb restoretimeout[]; .lg.o[`reload;"Finished reloading RDB"]; - {.rdb.reloadcalls[x]:0} each key .rdb.reloadcalls; + @[`.rdb.reloadcalls[x]:0; key .rdb.reloadcalls;:;0b]; }; // dictionary of handles to reload From c91eb3211d195354cbde132cfeb1f1f3543b0522 Mon Sep 17 00:00:00 2001 From: CReid Date: Fri, 5 May 2023 11:27:56 +0100 Subject: [PATCH 07/13] modification to functionality when a port closes --- code/hdb/hdbstandard.q | 2 +- code/processes/gateway.q | 2 +- code/processes/rdb.q | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index 65bd4a7b1..e0861cf5e 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -22,5 +22,5 @@ po:{[h] if[.z.u in `wdb`rdb;reloadcalls[h]:0b]}; .z.po:{[f;x] @[f;x;()];.hdb.po x} @[value;`.z.po;{{}}]; // function to remove handle from reloadcalls dictionary -pc:{[h] reloadcalls _: h; if[all value .hdb.reloadcalls;reload[]]}; +pc:{[h] reloadcalls _: h; if[all .hdb.reloadcalls;reload[]]}; .z.pc:{[f;x] @[f;x;()];.hdb.pc x} @[value;`.z.pc;{{}}]; diff --git a/code/processes/gateway.q b/code/processes/gateway.q index 690f2bab0..ddb3e797d 100644 --- a/code/processes/gateway.q +++ b/code/processes/gateway.q @@ -653,5 +653,5 @@ po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]}; .z.po:{[f;x] @[f;x;()];.gwreload.po x} @[value;`.z.po;{{}}]; // function to remove handle from reloadcalls dictionary -pc:{[h] reloadcalls _: h; if[all .gwreload.reloadcalls;reload[]]}; +pc:{[h] reloadcalls _: h; if[(all .gwreload.reloadcalls) & count .gwreload.reloadcalls;reload[]]}; .z.pc:{[f;x] @[f;x;()];.gwreload.pc x} @[value;`.z.pc;{{}}]; diff --git a/code/processes/rdb.q b/code/processes/rdb.q index a560ae82e..594cd8d56 100644 --- a/code/processes/rdb.q +++ b/code/processes/rdb.q @@ -146,7 +146,7 @@ po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]}; .z.po:{[f;x] @[f;x;()];.rdb.po x} @[value;`.z.po;{{}}]; // function to remove handle from reloadcalls dictionary -pc:{[h] reloadcalls _: h; if[all value .rdb.reloadcalls;reload[]]}; +pc:{[h] reloadcalls _: h; if[(all .rdb.reloadcalls) & count .rdb.reloadcalls;reload[]]}; .z.pc:{[f;x] @[f;x;()];.rdb.pc x} @[value;`.z.pc;{{}}]; /-drop date from rdbpartition From c5e560015c451b19d1d08447d1adc23796c77e91 Mon Sep 17 00:00:00 2001 From: CReid Date: Fri, 5 May 2023 15:48:41 +0100 Subject: [PATCH 08/13] hdb will not reload when no handles are connected --- code/hdb/hdbstandard.q | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index e0861cf5e..d7f185ecd 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -22,5 +22,5 @@ po:{[h] if[.z.u in `wdb`rdb;reloadcalls[h]:0b]}; .z.po:{[f;x] @[f;x;()];.hdb.po x} @[value;`.z.po;{{}}]; // function to remove handle from reloadcalls dictionary -pc:{[h] reloadcalls _: h; if[all .hdb.reloadcalls;reload[]]}; +pc:{[h] reloadcalls _: h; if[(all .hdb.reloadcalls) & count .hdb.reloadcalls;reload[]]}; .z.pc:{[f;x] @[f;x;()];.hdb.pc x} @[value;`.z.pc;{{}}]; From 6f62e2b547d94387cbcc030fbc9e5e80b64a2914 Mon Sep 17 00:00:00 2001 From: CReid Date: Mon, 5 Jun 2023 16:46:31 +0100 Subject: [PATCH 09/13] -bugfix in rdb.q file -added unit tests --- code/processes/rdb.q | 2 +- tests/syncreload/connections/.run.sh.swp | Bin 0 -> 12288 bytes tests/syncreload/connections/connections.csv | 21 +++++++++++++++++ tests/syncreload/connections/process.csv | 8 +++++++ tests/syncreload/connections/run.sh | 23 +++++++++++++++++++ tests/syncreload/connections/settings.q | 6 +++++ tests/syncreload/eod/endofday.csv | 13 +++++++++++ tests/syncreload/eod/process.csv | 8 +++++++ tests/syncreload/eod/run.sh | 23 +++++++++++++++++++ tests/syncreload/eod/settings.q | 6 +++++ 10 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 tests/syncreload/connections/.run.sh.swp create mode 100644 tests/syncreload/connections/connections.csv create mode 100644 tests/syncreload/connections/process.csv create mode 100755 tests/syncreload/connections/run.sh create mode 100644 tests/syncreload/connections/settings.q create mode 100644 tests/syncreload/eod/endofday.csv create mode 100644 tests/syncreload/eod/process.csv create mode 100755 tests/syncreload/eod/run.sh create mode 100644 tests/syncreload/eod/settings.q diff --git a/code/processes/rdb.q b/code/processes/rdb.q index 594cd8d56..d21e07cc0 100644 --- a/code/processes/rdb.q +++ b/code/processes/rdb.q @@ -135,7 +135,7 @@ reload:{[date] /-restore original timeout back to rdb restoretimeout[]; .lg.o[`reload;"Finished reloading RDB"]; - @[`.rdb.reloadcalls[x]:0; key .rdb.reloadcalls;:;0b]; + @[`.rdb.reloadcalls; key .rdb.reloadcalls;:;0b]; }; // dictionary of handles to reload diff --git a/tests/syncreload/connections/.run.sh.swp b/tests/syncreload/connections/.run.sh.swp new file mode 100644 index 0000000000000000000000000000000000000000..377b7fd75d53aeefb32c38978ce69eb65fcaf8b4 GIT binary patch literal 12288 zcmeI2&u`N(6vsUzBrf|QH~ScSPNJ<-8MaqA^z(nTo_{ ztrDLb?S!p#?6PB4BQp^o0w*J|$gZt->YsY+>MFl*{=vx}CvPG^1c(3;AOb{y2oM1x zKm<-T0bee#mpH+h<`fs3apBO|+|obDnC(w0h3Hpw8zd)a% z4^Y_WIYf;J5CI}U1c(3;AOb{y2oM1x@Lv&#_Ium+cQ&`THm1TGJ3_HDcixof$_~%c zeuvwpTj%3&)lS?VkM={=bSZr{6{R(aaxR9QwRktHJWtJ7^I&(3aUP|rUk!LvuN#eR z?iG(lRjxcH+o-Vi`4ARd@JGQC9^B0fn2z3M<`n|4%2kDTaJ+l_R&S%*>rMs25{+HV zJVR0UoJ*#PQrX=~&x*X`(cDf>d7tZngSieTZ1lUsuOR)TRJ@+9W7ZPK2)7-$h{{>f z&$Y0{*vgWJJr1D`>jRjV*3VW62WRXLzd9ws>7R2_Z_(r<1Q-%`a}L^()$fSz9z3}> zv-r~7qAuRp31iMwHbI6CxQpFF4oYdA3gz-GzA1Hz3?^nc#8tb Date: Tue, 6 Jun 2023 10:58:27 +0100 Subject: [PATCH 10/13] changes to unit tests --- tests/syncreload/connections/.run.sh.swp | Bin 12288 -> 0 bytes tests/syncreload/connections/process.csv | 14 +++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 tests/syncreload/connections/.run.sh.swp diff --git a/tests/syncreload/connections/.run.sh.swp b/tests/syncreload/connections/.run.sh.swp deleted file mode 100644 index 377b7fd75d53aeefb32c38978ce69eb65fcaf8b4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&u`N(6vsUzBrf|QH~ScSPNJ<-8MaqA^z(nTo_{ ztrDLb?S!p#?6PB4BQp^o0w*J|$gZt->YsY+>MFl*{=vx}CvPG^1c(3;AOb{y2oM1x zKm<-T0bee#mpH+h<`fs3apBO|+|obDnC(w0h3Hpw8zd)a% z4^Y_WIYf;J5CI}U1c(3;AOb{y2oM1x@Lv&#_Ium+cQ&`THm1TGJ3_HDcixof$_~%c zeuvwpTj%3&)lS?VkM={=bSZr{6{R(aaxR9QwRktHJWtJ7^I&(3aUP|rUk!LvuN#eR z?iG(lRjxcH+o-Vi`4ARd@JGQC9^B0fn2z3M<`n|4%2kDTaJ+l_R&S%*>rMs25{+HV zJVR0UoJ*#PQrX=~&x*X`(cDf>d7tZngSieTZ1lUsuOR)TRJ@+9W7ZPK2)7-$h{{>f z&$Y0{*vgWJJr1D`>jRjV*3VW62WRXLzd9ws>7R2_Z_(r<1Q-%`a}L^()$fSz9z3}> zv-r~7qAuRp31iMwHbI6CxQpFF4oYdA3gz-GzA1Hz3?^nc#8tb Date: Tue, 20 Jun 2023 10:24:25 +0100 Subject: [PATCH 11/13] adding unit tests --- code/hdb/hdbstandard.q | 2 +- tests/syncreload/connections.csv | 18 +++++++++++++++ tests/syncreload/connections/connections.csv | 21 ----------------- tests/syncreload/connections/process.csv | 8 ------- tests/syncreload/connections/run.sh | 23 ------------------- tests/syncreload/eod.csv | 17 ++++++++++++++ tests/syncreload/eod/endofday.csv | 13 ----------- tests/syncreload/eod/process.csv | 8 ------- tests/syncreload/eod/settings.q | 6 ----- tests/syncreload/process.csv | 8 +++++++ tests/syncreload/rdb2.q | 2 ++ tests/syncreload/{eod => }/run.sh | 8 +++---- tests/syncreload/{connections => }/settings.q | 0 13 files changed, 50 insertions(+), 84 deletions(-) create mode 100644 tests/syncreload/connections.csv delete mode 100644 tests/syncreload/connections/connections.csv delete mode 100644 tests/syncreload/connections/process.csv delete mode 100755 tests/syncreload/connections/run.sh create mode 100644 tests/syncreload/eod.csv delete mode 100644 tests/syncreload/eod/endofday.csv delete mode 100644 tests/syncreload/eod/process.csv delete mode 100644 tests/syncreload/eod/settings.q create mode 100644 tests/syncreload/process.csv create mode 100644 tests/syncreload/rdb2.q rename tests/syncreload/{eod => }/run.sh (59%) rename tests/syncreload/{connections => }/settings.q (100%) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index d7f185ecd..385b9529d 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -7,7 +7,7 @@ reload:{ if[not all .hdb.reloadcalls;:(::)]]; .lg.o[`reload;"reloading HDB"]; @[`.hdb.reloadcalls;key .hdb.reloadcalls;:;0b]; - system"l .";.[`.hdb.reloadcalls;();:;0];} + system"l ."} // Get the relevant HDB attributes .proc.getattributes:{`date`tables!(@[value;`date;`date$()];tables[])} diff --git a/tests/syncreload/connections.csv b/tests/syncreload/connections.csv new file mode 100644 index 000000000..f6c33abce --- /dev/null +++ b/tests/syncreload/connections.csv @@ -0,0 +1,18 @@ +action,ms,bytes,lang,code,repeat,minver,comment +beforeany,0,0,q,system "sleep 5",1,,"wait for all procs to go up" +before,0,0,q,hdbHandle:hopen`::41804:admin:admin,1,,"Get handle to the HDB" +before,0,0,q,rdb1Handle:hopen`::41802:admin:admin,1,,"Get handle to RDB1" +before,0,0,q,rdb2Handle:hopen`::41803:admin:admin,1,,"Get handle to RDB2" +before,0,0,q,wdbHandle:hopen`::41805:admin:admin,1,,"Get handle to WDB" +before,0,0,q,gwHandle:hopen`::41806:admin:admin,1,,"Get handle to gateway" +true,0,0,q,2~count hdbHandle(value;`.hdb.reloadcalls),1,,"check number of connections to the HDB" +true,0,0,q,1~count rdb1Handle(value;`.rdb.reloadcalls),1,,"check number of connections to RDB1" +true,0,0,q,1~count rdb2Handle(value;`.rdb.reloadcalls),1,,"check number of connections to RDB12" +true,0,0,q,1~count gwHandle(value;`.gwreload.reloadcalls),1,,"check number of connections to the gateway" +run,0,0,q,kill9proc["rdb1"],1,,"shut down rdb1 process" +run,0,0,q,system "sleep 5",1,,"to ensure rdb1 shuts down" +true,0,0,q,2~count hdbHandle(value;`.hdb.reloadcalls),1,,"recheck number of connections to the HDB" +true,0,0,q,1~count rdb2Handle(value;`.rdb.reloadcalls),1,,"recheck number of connections to RDB2" +run,0,0,q,kill9proc["rdb2"],1,,"shut down rdb2 process" +run,0,0,q,system "sleep 5",1,,"to ensure rdb2 shuts down" +true,0,0,q,1~count hdbHandle(value;`.hdb.reloadcalls),1,,"recheck number of connections to the HDB" diff --git a/tests/syncreload/connections/connections.csv b/tests/syncreload/connections/connections.csv deleted file mode 100644 index dbaa4508e..000000000 --- a/tests/syncreload/connections/connections.csv +++ /dev/null @@ -1,21 +0,0 @@ -action,ms,bytes,lang,code,repeat,minver,comment -beforeany,0,0,q,system "sleep 5",1,,"wait for all procs to go up" -before,0,0,q,hdbHandle:gethandle[`hdb1],1,,"Get handle to the HDB" -before,0,0,q,rdb1Handle:gethandle[`rdb1],1,,"Get handle to RDB1" -before,0,0,q,rdb2Handle:gethandle[`rdb2],1,,"Get handle to RDB2" -before,0,0,q,wdbHandle:gethandle[`wdb1],1,,"Get handle to WDB" -before,0,0,q,gwHandle:gethandle[`gateway1],1,,"Get handle to gateway" -before,0,0,q,gwconnections:gwHandle(`.gw.reloadcalls;`),1,,"get list of connections to the gateway" -true,0,0,q,2~count hdbHandle(`.hdb.reloadcalls;`),1,,"check number of connections to the HDB" -true,0,0,q,1~count rdb1Handle(`.rdb.reloadcalls;`),1,,"check number of connections to RDB1" -true,0,0,q,1~count rdb2Handle(`.rdb.reloadcalls;`),1,,"check number of connections to RDB12" -true,0,0,q,2~count gwHandle(`.gw.reloadcalls;`),1,,"check number of connections to the gateway" -run,0,0,q,system "kill -15 rdb1",1,,"shut down rdb1 process" -run,0,0,q,system "sleep 5",1,,"to ensure rdb1 shuts down" -true,0,0,q,2~count hdbHandle(`.hdb.reloadcalls;`),1,,"check number of connections to the HDB" -true,0,0,q,1~count rdb2Handle(`.rdb.reloadcalls;`),1,,"check number of connections to RDB2" -true,0,0,q,2~count gwHandle(`.gw.reloadcalls;`),1,,"check number of connections to the gateway" -run,0,0,q,system "kill -15 rdb2",1,,"shut down rdb2 process" -run,0,0,q,system "sleep 5",1,,"to ensure rdb2 shuts down" -true,0,0,q,2~count hdbHandle(`.hdb.reloadcalls;`),1,,"check number of connections to the HDB" -true,0,0,q,2~count gwHandle(`.gw.reloadcalls;`),1,,"check number of connections to the gateway" diff --git a/tests/syncreload/connections/process.csv b/tests/syncreload/connections/process.csv deleted file mode 100644 index fc5861c15..000000000 --- a/tests/syncreload/connections/process.csv +++ /dev/null @@ -1,8 +0,0 @@ -host,port,proctype,procname,U,localtime,g,T,w,load,startwithall,extras,qcmd -localhost,{KDBBASEPORT}+1,discovery,discovery1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/discovery.q,1,,q -localhost,{KDBBASEPORT},segmentedtickerplant,stp1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,,q -localhost,{KDBBASEPORT}+2,rdb,rdb1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,,q -localhost,{KDBBASEPORT}+3,rdb,rdb2,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,-.rdb.hdbtypes enlist `hdb -.servers.CONNECTIONS `gateway`hdb,q -localhost,{KDBBASEPORT}+4,wdb,wdb1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/wdb.q,1,,q -localhost,{KDBBASEPORT}+5,hdb,hdb1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/hdb.q,1,,q -localhost,{KDBBASEPORT}+6,gateway,gw,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/gateway.q,1,,q diff --git a/tests/syncreload/connections/run.sh b/tests/syncreload/connections/run.sh deleted file mode 100755 index 899f356c3..000000000 --- a/tests/syncreload/connections/run.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Handle command-line arguments -source $KDBTESTS/flagparse.sh - -# Path to test directory -testpath=${KDBTESTS}/syncreload/connections - -# Start procs -${TORQHOME}/torq.sh start stp1 hdb1 rdb1 rdb2 wdb1 -csv ${testpath}/process.csv - -# Start test proc -/usr/bin/rlwrap q ${TORQHOME}/torq.q \ - -proctype test -procname test1 \ - -test ${testpath} \ - -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -testresults ${KDBTESTS}/stp/results/ \ - -procfile ${testpath}/process.csv \ - -runtime $run \ - $debug $stop $write $quiet - -# Shut down procs -${TORQHOME}/torq.sh stop stp1 hdb1 rdb1 rdb2 wdb1 -csv ${testpath}/process.csv diff --git a/tests/syncreload/eod.csv b/tests/syncreload/eod.csv new file mode 100644 index 000000000..0740b6d2a --- /dev/null +++ b/tests/syncreload/eod.csv @@ -0,0 +1,17 @@ +action,ms,bytes,lang,code,repeat,minver,comment +beforeany,0,0,q,system "sleep 5",1,,"wait for all procs to go up" +before,0,0,q,hdbHandle:hopen`::41804:admin:admin,1,,"Get handle to the HDB" +before,0,0,q,rdb1Handle:hopen`::41802:admin:admin,1,,"Get handle to RDB1" +before,0,0,q,rdb2Handle:hopen`::41803:admin:admin,1,,"Get handle to RDB2" +before,0,0,q,wdbHandle:hopen`::41805:admin:admin,1,,"Get handle to WDB" +before,0,0,q,gwHandle:hopen`::41806:admin:admin,1,,"Get handle to gateway" +true,0,0,q,0=all rdb1Handle(value;`.rdb.reloadcalls),1,,"check rdb1 reloadcalls dictionary" +true,0,0,q,0=all rdb2Handle(value;`.rdb.reloadcalls),1,,"check rdb2 reloadcalls dictionary" +true,0,0,q,0=all gwHandle(value;`.gwreload.reloadcalls),1,,"check gateway reloadcalls dictionary" +true,0,0,q,0=all hdbHandle(value;`.hdb.reloadcalls),1,,"check hdb reloadcalls dictionary" +run,0,0,q,wdbHandle(`.u.end;.z.d) +run,0,0,q,system "sleep 5",1,,"wait to allow wdb endofday process to finish running" +true,0,0,q,1=all rdb1Handle(value;`.rdb.reloadcalls),1,,"check rdb1 reloadcalls dictionary has updated" +true,0,0,q,0=all rdb2Handle(value;`.rdb.reloadcalls),1,,"check rdb2 reloadcalls dictionary has not updated" +true,0,0,q,0=all gwHandle(value;`.gwreload.reloadcalls),1,,"check gateway reloadcalls dictionary has updated" +true,0,0,q,1=sum hdbHandle(value;`.hdb.reloadcalls),1,,"check hdb reloadcalls dictionary has updated" diff --git a/tests/syncreload/eod/endofday.csv b/tests/syncreload/eod/endofday.csv deleted file mode 100644 index d9f741d1b..000000000 --- a/tests/syncreload/eod/endofday.csv +++ /dev/null @@ -1,13 +0,0 @@ -action,ms,bytes,lang,code,repeat,minver,comment -beforeany,0,0,q,system "sleep 5",1,,"wait for all procs to go up" -before,0,0,q,hdbHandle:gethandle[`hdb1],1,,"Get handle to the HDB" -before,0,0,q,rdb1Handle:gethandle[`rdb1],1,,"Get handle to RDB1" -before,0,0,q,rdb2Handle:gethandle[`rdb2],1,,"Get handle to RDB2" -before,0,0,q,wdbHandle:gethandle[`wdb1],1,,"Get handle to WDB" -before,0,0,q,gwHandle:gethandle[`gateway1],1,,"Get handle to gateway" -run,0,0,q,wdbHandle(`.u.endofday;.z.d) -run,0,0,q,system "sleep 5",1,,"wait to allow wdb endofday process to finish running" -true,0,0,q,1~all rdb1Handle(`.rdb.reloadcalls),1,,"check rdb1 reloadcalls dictionary has updated" -true,0,0,q,0~all rdb2Handle(`.rdb.reloadcalls),1,,"check rdb2 reloadcalls dictionary has not updated" -true,0,0,q,1~sum gwHandle(`.gw.reloadcalls),1,,"check gateway reloadcalls dictionary has updated" -true,0,0,q,1~sum hdbHandle(`.hdb.reloadcalls),1,,"check hdb reloadcalls dictionary has updated" diff --git a/tests/syncreload/eod/process.csv b/tests/syncreload/eod/process.csv deleted file mode 100644 index 8c047a2c4..000000000 --- a/tests/syncreload/eod/process.csv +++ /dev/null @@ -1,8 +0,0 @@ -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}+100,segmentedtickerplant,stp1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,,q -localhost,{KDBBASEPORT}+101,rdb,rdb1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,,q -localhost,{KDBBASEPORT}+102,rdb,rdb2,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,-.rdb.hdbtypes enlist `hdb -.servers.CONNECTIONS `gateway`hdb,q -localhost,{KDBBASEPORT}+104,wdb,wdb1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/wdb.q,1,,q -localhost,{KDBBASEPORT}+105,hdb,hdb,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/hdb.q,1,,q -localhost,{KDBBASEPORT}+106,gateway,gw,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/gateway.q,1,,q diff --git a/tests/syncreload/eod/settings.q b/tests/syncreload/eod/settings.q deleted file mode 100644 index 037130c70..000000000 --- a/tests/syncreload/eod/settings.q +++ /dev/null @@ -1,6 +0,0 @@ -// IPC connection parameters -.servers.CONNECTIONS:`rdb`segmentedtickerplant; -.servers.USERPASS:`admin:admin; - -// Paths to process CSV and test STP log directory -processcsv:getenv[`KDBTESTS],"/syncreload/connections/process.csv"; diff --git a/tests/syncreload/process.csv b/tests/syncreload/process.csv new file mode 100644 index 000000000..1d3741cb9 --- /dev/null +++ b/tests/syncreload/process.csv @@ -0,0 +1,8 @@ +host,port,proctype,procname,U,localtime,g,T,w,load,startwithall,extras,qcmd +localhost,{KDBBASEPORT}+1,discovery,discovery1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/discovery.q,1,, +localhost,{KDBBASEPORT},segmentedtickerplant,stp1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-schemafile ${TORQAPPHOME}/database.q -tplogdir ${KDBTPLOG}, +localhost,{KDBBASEPORT}+2,rdb,rdb1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,, +localhost,{KDBBASEPORT}+3,rdb,rdb2,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,, +localhost,{KDBBASEPORT}+4,hdb,hdb1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,1,60,4000,${KDBHDB},1,, +localhost,{KDBBASEPORT}+5,wdb,wdb1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,1,,,${KDBCODE}/processes/wdb.q,1,, +localhost,{KDBBASEPORT}+6,gateway,gateway1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,1,,4000,${KDBCODE}/processes/gateway.q,1,, diff --git a/tests/syncreload/rdb2.q b/tests/syncreload/rdb2.q new file mode 100644 index 000000000..62f453a3d --- /dev/null +++ b/tests/syncreload/rdb2.q @@ -0,0 +1,2 @@ +.rdb.hdbtypes:enlist`hdb +.servers.CONNECTIONS:`gateway`hdb diff --git a/tests/syncreload/eod/run.sh b/tests/syncreload/run.sh similarity index 59% rename from tests/syncreload/eod/run.sh rename to tests/syncreload/run.sh index cd2ead6f2..297890fe3 100755 --- a/tests/syncreload/eod/run.sh +++ b/tests/syncreload/run.sh @@ -4,20 +4,20 @@ source $KDBTESTS/flagparse.sh # Path to test directory -testpath=${KDBTESTS}/syncreload/eod +testpath=/home/creid/devTorQ/bin/syncreload # Start procs -${TORQHOME}/torq.sh start discovery1 stp1 hdb1 rdb1 rdb2 rdb3 wdb1 -csv ${testpath}/process.csv +bin/torq.sh start discovery1 stp1 hdb1 rdb1 rdb2 wdb1 gateway1 -csv ${testpath}/process.csv # Start test proc /usr/bin/rlwrap q ${TORQHOME}/torq.q \ -proctype test -procname test1 \ -test ${testpath} \ -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -testresults ${KDBTESTS}/stp/results/ \ + -testresults ${KDBTESTS}/syncreload/results/ \ -procfile ${testpath}/process.csv \ -runtime $run \ $debug $stop $write $quiet # Shut down procs -${TORQHOME}/torq.sh stop stp1 hdb1 rdb1 rdb2 wdb1 -csv ${testpath}/process.csv +bin/torq.sh stop discovery1 stp1 hdb1 rdb1 rdb2 wdb1 gateway1 -csv ${testpath}/process.csv diff --git a/tests/syncreload/connections/settings.q b/tests/syncreload/settings.q similarity index 100% rename from tests/syncreload/connections/settings.q rename to tests/syncreload/settings.q From ee9bcade3d9f5503661db156cfd8b4ca4cca6eb2 Mon Sep 17 00:00:00 2001 From: Callum Date: Thu, 27 Jul 2023 11:06:57 +0100 Subject: [PATCH 12/13] making requested changes and bug fixes --- code/hdb/hdbstandard.q | 10 ++++++---- code/processes/gateway.q | 14 ++++++++++---- code/processes/rdb.q | 12 ++++++++---- config/settings/gateway.q | 3 +++ config/settings/hdb.q | 3 +++ 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/code/hdb/hdbstandard.q b/code/hdb/hdbstandard.q index 385b9529d..3ce195f66 100644 --- a/code/hdb/hdbstandard.q +++ b/code/hdb/hdbstandard.q @@ -1,10 +1,12 @@ // reload function reload:{ - if[.z.w in key .hdb.reloadcalls; .hdb.reloadcalls[.z.w]:1b; - .lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .hdb.reloadcalls]; - if[not all .hdb.reloadcalls;:(::)]]; + $[not all .hdb.reloadcalls; + {.lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .hdb.reloadcalls]; :(::)}[]; + .lg.o[`reload;"reload call received from handle ", string[.z.w], "; no more reload calls pending"]; + ] + ] .lg.o[`reload;"reloading HDB"]; @[`.hdb.reloadcalls;key .hdb.reloadcalls;:;0b]; system"l ."} @@ -18,7 +20,7 @@ reload:{ reloadcalls:()!(); // function to add handle to reloadcalls dictionary -po:{[h] if[.z.u in `wdb`rdb;reloadcalls[h]:0b]}; +po:{[h] if[.proc.proctype in .hdb.connectedProcs;reloadcalls[h]:0b]}; .z.po:{[f;x] @[f;x;()];.hdb.po x} @[value;`.z.po;{{}}]; // function to remove handle from reloadcalls dictionary diff --git a/code/processes/gateway.q b/code/processes/gateway.q index ddb3e797d..7b7af13a5 100644 --- a/code/processes/gateway.q +++ b/code/processes/gateway.q @@ -552,8 +552,11 @@ reloadstart:{ reloadend:{ if[.z.w in key .gw.reloadcalls; .gw.reloadcalls[.z.w]:1b; - .lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .gw.reloadcalls]; - if[not all .gw.reloadcalls;:(::)]]; + $[not all .gw.reloadcalls; + {.lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .gw.reloadcalls]; :(::)}[]; + .lg.o[`reload;"reload call received from handle ", string[.z.w], "; no more reload calls pending"]; + ] + ] .lg.o[`reload;"reload end called"]; /- set eod variable to false @@ -562,7 +565,8 @@ reloadend:{ /- retry connections - get updated attributes from servers and refresh servers tables setattributes .' flip value flip select procname,proctype,@[;(`.proc.getattributes;`);()!()] each w from .servers.SERVERS where .dotz.liveh[w]; /- flush any async queries held during reload phase - .gw.runnextquery[];} + .gw.runnextquery[]; + } setattributes:{ [prcnme;prctyp;att] /- get relevant atrributes @@ -643,13 +647,15 @@ neg[h](`.gw.asyncexecjpt;(`.q.system;"sleep 10");enlist[`servertype]!enlist`rdb` h(`.gw.syncexec;"`$last .z.x";enlist[`tables]!enlist enlist`logmsgXXX) h(`.gw.syncexec;"`$last .z.x";`tables`servertype!(enlist`data;`rdb`hdb)) +\ + \d .gwreload // dictionary of handles to reload reloadcalls:()!(); // function to add handle to reloadcalls dictionary -po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]}; +po:{[h] if[.proc.proctype in .gw.connectedProcs;reloadcalls[h]:0b]}; .z.po:{[f;x] @[f;x;()];.gwreload.po x} @[value;`.z.po;{{}}]; // function to remove handle from reloadcalls dictionary diff --git a/code/processes/rdb.q b/code/processes/rdb.q index d21e07cc0..22f7001ae 100644 --- a/code/processes/rdb.q +++ b/code/processes/rdb.q @@ -115,9 +115,13 @@ endofday:{[date;processdata] reload:{[date] if[.z.w in key .rdb.reloadcalls; - .rdb.reloadcalls[.z.w]:1b; - .lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .rdb.reloadcalls]; - if[not all .rdb.reloadcalls;:(::)]]; + .rdb.reloadcalls[.z.w]:1b; + $[not all .rdb.reloadcalls; + {.lg.o[`reload;"reload call received from handle ", string[.z.w], "; reload calls pending from handles ", ", "sv string where not .rdb.reloadcalls]; :(::)}[]; + .lg.o[`reload;"reload call received from handle ", string[.z.w], "; no more reload calls pending"]; + ] + ] + .lg.o[`reload;"reload command has been called remotely"]; /-get all attributes from all tables before they are wiped /-get a list of pairs (tablename;columnname!attributes) @@ -142,7 +146,7 @@ reload:{[date] reloadcalls:()!(); // function to add handle to reloadcalls dictionary -po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]}; +po:{[h] if[.proc.proctype in .rdb.connectedProcs;reloadcalls[h]:0b]}; .z.po:{[f;x] @[f;x;()];.rdb.po x} @[value;`.z.po;{{}}]; // function to remove handle from reloadcalls dictionary diff --git a/config/settings/gateway.q b/config/settings/gateway.q index 820c6c9bc..192e390d8 100644 --- a/config/settings/gateway.q +++ b/config/settings/gateway.q @@ -9,6 +9,9 @@ querykeeptime:0D00:30 // the time to keep queries in the errorprefix:"error: " // the prefix for clients to look for in error strings clearinactivetime:0D01:00 // the time to keep inactive handle data +// list of process types connected for sync reload +connectedProcs:() + \d .kxdash enabled:0b // Functionality for parsing and handling kx dashboard queries - disabled by default diff --git a/config/settings/hdb.q b/config/settings/hdb.q index e89d9a53e..b2032cc1e 100644 --- a/config/settings/hdb.q +++ b/config/settings/hdb.q @@ -7,3 +7,6 @@ loadprocesscode:1b // whether to load the process specific code def \d .servers CONNECTIONS:() // list of connections to make at start up STARTUP:1b // create connections + +// list of processes connected for sync reload +.hdb.connectedProcs:() \ No newline at end of file From 8d96210d2230d0f8025e9001e47a3eb6f13ec9cb Mon Sep 17 00:00:00 2001 From: Callum Date: Mon, 31 Jul 2023 15:51:57 +0100 Subject: [PATCH 13/13] modification to gateway.q syntax --- code/processes/gateway.q | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/code/processes/gateway.q b/code/processes/gateway.q index 7b7af13a5..4884ac07a 100644 --- a/code/processes/gateway.q +++ b/code/processes/gateway.q @@ -597,6 +597,18 @@ if[@[value;`.timer.enabled;0b]; f@connectiontab }@[value;`.servers.connectcustom;{{[x]}}] +\d .gwreload + +// dictionary of handles to reload +reloadcalls:()!(); + +// function to add handle to reloadcalls dictionary +po:{[h] if[.proc.proctype in .gw.connectedProcs;reloadcalls[h]:0b]}; +.z.po:{[f;x] @[f;x;()];.gwreload.po x} @[value;`.z.po;{{}}]; + +// function to remove handle from reloadcalls dictionary +pc:{[h] reloadcalls _: h; if[(all .gwreload.reloadcalls) & count .gwreload.reloadcalls;reload[]]}; +.z.pc:{[f;x] @[f;x;()];.gwreload.pc x} @[value;`.z.pc;{{}}]; / @@ -645,19 +657,4 @@ neg[h](`.gw.asyncexec;"`$last .z.x";enlist[`tables]!enlist enlist`logmsgXXX);h[] neg[h](`.gw.asyncexec;"`$last .z.x";`tables`servertype!(enlist`data;`rdb`hdb));h[] neg[h](`.gw.asyncexecjpt;(`.q.system;"sleep 10");enlist[`servertype]!enlist`rdb`hdb;raze;();0D00:00:03);h[] h(`.gw.syncexec;"`$last .z.x";enlist[`tables]!enlist enlist`logmsgXXX) -h(`.gw.syncexec;"`$last .z.x";`tables`servertype!(enlist`data;`rdb`hdb)) - -\ - -\d .gwreload - -// dictionary of handles to reload -reloadcalls:()!(); - -// function to add handle to reloadcalls dictionary -po:{[h] if[.proc.proctype in .gw.connectedProcs;reloadcalls[h]:0b]}; -.z.po:{[f;x] @[f;x;()];.gwreload.po x} @[value;`.z.po;{{}}]; - -// function to remove handle from reloadcalls dictionary -pc:{[h] reloadcalls _: h; if[(all .gwreload.reloadcalls) & count .gwreload.reloadcalls;reload[]]}; -.z.pc:{[f;x] @[f;x;()];.gwreload.pc x} @[value;`.z.pc;{{}}]; +h(`.gw.syncexec;"`$last .z.x";`tables`servertype!(enlist`data;`rdb`hdb)) \ No newline at end of file