Skip to content

Commit 7e9f4bc

Browse files
authored
adding replaymaxrows for optional row count on recovery (#688)
1 parent 18e4f07 commit 7e9f4bc

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

code/processes/wdb.q

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,15 @@ replayupd:{[f;t;d]
552552
/- execute the supplied function
553553
f . (t;d);
554554
/- if the data count is greater than the threshold, then flush data to disk
555-
if[(rpc:count[value t]) > lmt:maxrows[t];
556-
.lg.o[`replayupd;"row limit (",string[lmt],") exceeded for ",string[t],". Table count is : ",string[rpc],". Flushing table to disk..."];
557-
savetables[savedir;getpartition[];0b;t]]
555+
replaymaxrowcheck[t;replaymaxrows[t]];
558556
}[upd];
559557

558+
replaymaxrowcheck:{[t;lmt]
559+
if[(rpc:count[value t]) > lmt;
560+
.lg.o[`replayupd;"row limit (",string[lmt],") exceeded for ",string[t],". Table count is : ",string[rpc],". Flushing table to disk..."];
561+
savetables[savedir;getpartition[];0b;t]];
562+
};
563+
560564
/ - if there is data in the wdb directory for the partition remove it before replay
561565
/ - is only for wdb processes that are saving data to disk
562566
clearwdbdata:{[]

code/wdb/origstartup.q

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ startup:{[]
1616
subscribe[];
1717
/- add missing tables to partitions in case an IDB process wants to connect. Only applicable for partbyenum writedown mode
1818
if[.wdb.writedownmode in `default`partbyenum;initmissingtables[currentpartition]];
19+
// if for replay table maxrows were customised, we want to check row count for each table, save and gc where needed
20+
if[(not .wdb.numtab~.wdb.replaynumtab)or .wdb.numrows<>.wdb.replaynumrows;
21+
tabs:exec table from .sub.SUBSCRIPTIONS;
22+
tabmaxrowpairs:{(x;.wdb.maxrows[x])}each tabs;
23+
{replaymaxrowcheck[first x;last x]}each tabmaxrowpairs];
1924
];
2025
@[`.; `upd; :; .wdb.upd];
2126
}

code/wdb/writedown.q

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ numtab:@[value;`numtab;`quote`trade!10000 50000]; /-spe
1111

1212

1313
maxrows:{[tabname] numrows^numtab[tabname]}; /- extract user defined row counts
14+
replaymaxrows:{[tabname] replaynumrows^replaynumtab[tabname]};
1415

1516
partitiontype:@[value;`partitiontype;`date]; /-set type of partition (defaults to `date)
1617

config/settings/wdb.q

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ subsyms:`
1414
savedir:hsym`$getenv[`TORQHOME],"/wdbhdb" // location to save wdb data
1515
numrows:100000 // default number of rows
1616
numtab:`quote`trade!10000 50000 // specify number of rows per table
17+
replaynumrows:numrows // 0W for replaying all messages at once then flushing
18+
replaynumtab:numtab // enlist[`]!enlist 0W for replaying all messages at once then flushing
1719
mode:`save // the wdb process can operate in three modes
1820
// 1. saveandsort: the process will subscribe for data,
1921
// periodically write data to disk and at EOD it will flush

0 commit comments

Comments
 (0)