Skip to content

Commit ebce23d

Browse files
committed
- 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
1 parent e827a55 commit ebce23d

File tree

3 files changed

+51
-16
lines changed

3 files changed

+51
-16
lines changed

code/hdb/hdbstandard.q

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
// reload function
22
reload:{
3-
.hdb.expectedreloadcalls:count select from .clients.clients where u in `wdb`rdb, not null w;
4-
5-
.[`.hdb.reloadcalls;();+;1];
6-
.lg.o[`reload;string[.hdb.reloadcalls]," out of ",string[.hdb.expectedreloadcalls]," calls received"];
7-
if[.hdb.reloadcalls<.hdb.expectedreloadcalls;:(::)];
3+
4+
if[.z.w in key .hdb.reloadcalls;
5+
.hdb.reloadcalls[.z.w]:1b;
6+
.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];
7+
if[not all value .hdb.reloadcalls;:(::)]];
88
.lg.o[`reload;"reloading HDB"];
9+
{.hdb.reloadcalls[x]:0} each key .hdb.reloadcalls;
910
system"l .";.[`.hdb.reloadcalls;();:;0];}
1011

1112
// Get the relevant HDB attributes
1213
.proc.getattributes:{`date`tables!(@[value;`date;`date$()];tables[])}
14+
15+
\d .hdb
16+
17+
// dictionary of handles to reload
18+
reloadcalls:()!();
19+
20+
// function to add handle to reloadcalls dictionary
21+
po:{[h] if[.z.u in `wdb`rdb;reloadcalls[h]:0b]};
22+
.z.po:{[f;x] @[f;x;()];.hdb.po x} @[value;`.z.po;{{}}];
23+
24+
// function to remove handle from reloadcalls dictionary
25+
pc:{[h] reloadcalls _: h; if[all value .hdb.reloadcalls;reload[]]};
26+
.z.pc:{[f;x] @[f;x;()];.hdb.pc x} @[value;`.z.pc;{{}}];

code/processes/gateway.q

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,15 +550,15 @@ reloadstart:{
550550
};
551551

552552
reloadend:{
553-
.gw.expectedreloadcalls:;count select from .clients.clients where u in `wdb, not null w;
553+
if[.z.w in key .gw.reloadcalls;
554+
.gw.reloadcalls[.z.w]:1b;
555+
.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];
556+
if[not all value .gw.reloadcalls;:(::)]];
554557

555-
.[`.gw.reloadcalls;();+;1];
556-
.lg.o[`reload;string[.gw.reloadcalls]," out of ",string[.gw.expectedreloadcalls]," calls received"];
557-
if[.gw.reloadcalls<.gw.expectedreloadcalls;:(::)];
558558
.lg.o[`reload;"reload end called"];
559559
/- set eod variable to false
560560
.gw.seteod[0b];
561-
.[`.gw.reloadcalls;();:;0];
561+
{.gw.reloadcalls[x]:0} each key .gw.reloadcalls;
562562
/- retry connections - get updated attributes from servers and refresh servers tables
563563
setattributes .' flip value flip select procname,proctype,@[;(`.proc.getattributes;`);()!()] each w from .servers.SERVERS where .dotz.liveh[w];
564564
/- flush any async queries held during reload phase
@@ -643,4 +643,15 @@ neg[h](`.gw.asyncexecjpt;(`.q.system;"sleep 10");enlist[`servertype]!enlist`rdb`
643643
h(`.gw.syncexec;"`$last .z.x";enlist[`tables]!enlist enlist`logmsgXXX)
644644
h(`.gw.syncexec;"`$last .z.x";`tables`servertype!(enlist`data;`rdb`hdb))
645645
646+
\d .gwreload
646647
648+
// dictionary of handles to reload
649+
reloadcalls:()!();
650+
651+
// function to add handle to reloadcalls dictionary
652+
po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]};
653+
.z.po:{[f;x] @[f;x;()];.gwreload.po x} @[value;`.z.po;{{}}];
654+
655+
// function to remove handle from reloadcalls dictionary
656+
pc:{[h] reloadcalls _: h; if[all value .gwreload.reloadcalls;reload[]]};
657+
.z.pc:{[f;x] @[f;x;()];.gwreload.pc x} @[value;`.z.pc;{{}}];

code/processes/rdb.q

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,10 @@ endofday:{[date;processdata]
114114
};
115115

116116
reload:{[date]
117-
.rdb.expectedreloadcalls:count select from .clients.clients where u in `wdb, not null w;
118-
119-
.[`.rdb.reloadcalls;();+;1];
120-
.lg.o[`reload;string[.rdb.reloadcalls]," out of ",string[.rdb.expectedreloadcalls]," calls received"];
121-
if[.rdb.reloadcalls<.rdb.expectedreloadcalls;:(::)];
117+
if[.z.w in key .rdb.reloadcalls;
118+
.rdb.reloadcalls[.z.w]:1b;
119+
.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];
120+
if[not all value .rdb.reloadcalls;:(::)]];
122121
.lg.o[`reload;"reload command has been called remotely"];
123122
/-get all attributes from all tables before they are wiped
124123
/-get a list of pairs (tablename;columnname!attributes)
@@ -136,8 +135,19 @@ reload:{[date]
136135
/-restore original timeout back to rdb
137136
restoretimeout[];
138137
.lg.o[`reload;"Finished reloading RDB"];
139-
.[`.rdb.reloadcalls;();:;0];
138+
{.rdb.reloadcalls[x]:0} each key .rdb.reloadcalls;
140139
};
140+
141+
// dictionary of handles to reload
142+
reloadcalls:()!();
143+
144+
// function to add handle to reloadcalls dictionary
145+
po:{[h] if[.z.u in `wdb;reloadcalls[h]:0b]};
146+
.z.po:{[f;x] @[f;x;()];.rdb.po x} @[value;`.z.po;{{}}];
147+
148+
// function to remove handle from reloadcalls dictionary
149+
pc:{[h] reloadcalls _: h; if[all value .rdb.reloadcalls;reload[]]};
150+
.z.pc:{[f;x] @[f;x;()];.rdb.pc x} @[value;`.z.pc;{{}}];
141151

142152
/-drop date from rdbpartition
143153
rmdtfromgetpar:{[date]

0 commit comments

Comments
 (0)