Skip to content

Fix two bugs which break TorQ on every engine (dbwriteutils.q,html.q) - #770

Closed
jaen15marcos wants to merge 7 commits into
DataIntellectTech:masterfrom
jaen15marcos:bugfixes
Closed

jaen15marcos wants to merge 7 commits into
DataIntellectTech:masterfrom
jaen15marcos:bugfixes

Conversation

@jaen15marcos

@jaen15marcos jaen15marcos commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor
  • code/common/dbwriteutils.q: the default .save.postreplay was a projection of the error string (the trap passes the error to its handler), so every end-of-day which called .save.postreplay[dir;date] stopped with 'rank (introduced by Fix .save.postreplay default-overwrite #762)
  • code/common/html.q: wssub called sub, which builds a table schema, and the monitor's start subscribes lmchart, a function: 'type, so the monitor's start never completed

- code/common/dbwriteutils.q: the default .save.postreplay was a projection of
  the error string (the trap passes the error to its handler), so every
  end-of-day which called .save.postreplay[dir;date] stopped with 'rank
  (introduced by DataIntellectTech#762)
- code/common/html.q: wssub called sub, which builds a table schema, and the
  monitor's start subscribes lmchart, a function: 'type, so the monitor's
  start never completed
- tests/bugfixes: k4unit tests for both

@jonnypress jonnypress left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@jaen15marcos
jaen15marcos marked this pull request as ready for review November 11, 2026 01:18
partbyenum.csv triggers a WDB end of day and then checks the HDB. Before
the dbwriteutils.q fix in this PR, the default .save.postreplay stopped
that end of day with 'rank, so the trigger and both HDB checks failed.
The new row calls the WDB's hook with (dir;date), as wdb.q does at end of
day, so a regression fails with its cause named.

On KDB-X, master vs this PR: the trigger, the two HDB checks and the new
row fail on master and pass here; every other test is unchanged.
A new suite which starts a monitor and calls start, as its web page does
on every connection. start subscribes heartbeat, logmsg and lmchart with
.html.wssub; lmchart is a function, and the original wssub stopped with
'type on it, so start never returned its data. The checks: start runs;
calling it twice leaves one subscription each; each subscription is the
handle and ` (all syms), as the original wssub registers for a table;
wssub ` subscribes every value; an unknown name is still rejected.

Master fails the start and wssub ` checks with 'type; with the html.q
fix in this PR all pass on KDB-X, and with DataIntellectTech#769 also on L and PeachQ.
@jaen15marcos

Copy link
Copy Markdown
Contributor Author

Added testing coverage with latest commit

Running the tickerplant suites on several engines turned up failures
that are not engine differences at all: they fail on kdb+ on master.
Three are bugs in the segmented tickerplant, and the rest are tests that
fell behind the code. All of it is in tests/stp or the code those tests
exercise.

Tickerplant bugs

- End of day and end of period called .stpps.pubclear[.stplg.t]. That
  list is every table in the process, including logmsg, but pubclear
  resets each table from the publish schemas, which since DataIntellectTech#638 have no
  entry for logmsg. A dictionary of tables returns an empty copy of its
  first table for a key it doesn't have, so at every roll logmsg was
  quietly replaced by an empty table with another table's columns. The
  three calls now pass .stpps.t, as the batch code already does.
- The exit handler closed .stpps.t, the published tables, although a
  log is opened for every table. On a clean shutdown the logmsg log
  stayed open and its row in the meta table kept a null end time. It
  now closes .stplg.logtabs, the same list end of day uses.
- A chained tickerplant that is not creating logs replaces the
  loghandles view with a dictionary of no-ops (DataIntellectTech#368). If it was then
  switched to create its own logs, the logs were opened but nothing was
  written to them, because loghandles was still that dictionary. The
  view is now restored when a chained tickerplant opens logs.

Tests that were wrong

- stp/pubsub: seven rows from DataIntellectTech#391 call rdbHandle, which the suite
  never defines. They now use the suite's own publisher, with one row
  that gives it trades to filter.
- stp/eod and three chained suites still called .stplg.stpeod, which
  DataIntellectTech#523 folded into .stplg.endofday.
- stp/eod, stp/periodend, stp/chainedperiodend sized the meta table by
  the publish list, which is one short since DataIntellectTech#638.
- stp/tz upserted six values into the time zone table, which has had
  four columns since the tzinfo file was regenerated in DataIntellectTech#603.
- stp/custommode expects quote_iex, trade_iex and heartbeat. The
  Starter Pack dropped the _iex tables, so the suite now has its own
  schema file. It also moved the logs with setenv on KDBTPLOG, which
  the tickerplant has read once at start-up since DataIntellectTech#638; it now sets
  .stplg.kdbtplog. Its bad update is a one-item list and its file count
  is compared by value, so the same rows also hold on Korze and L.
- Seven run.sh passed -results where runtests.q reads -testresults, so
  those suites never wrote a results file; two also left out $write.
- helperfunctions.q: gethandle opened a new handle on every call and
  never closed the old one. A process has a limit on open connections,
  and stp/wdb reopened handles often enough to reach it.

On KDB-X 5.0, master against this branch: stp/pubsub 34/41 to 42/42,
eod 10/15 to 15/15, exit 4/5 to 5/5, periodend 6/8 to 8/8, tz 26/31 to
31/31, custommode 39/47 to 47/47, chainedstp 37/40 to 40/40, and
stp/wdb 73/96 to 96/96.
defbatch.csv resumes publication with .z.ts[] on the tickerplant and
checks the RDB's row count on the very next line. The tickerplant
publishes asynchronously, so the check raced the update: straight after
the call the RDB still had 10 rows, and a second later 11. membatch.csv
has the same sequence with a one-second wait in between ("Give data a
chance to publish"); defbatch.csv was missing that row.

On KDB-X the check failed about one run in three. With the wait,
tests/stp/batching passed six runs out of six.
When discovery connects to a process it asks for .servers.getdetails,
and a process started without TorQ's handlers (every tickerlogreplay
process, by default) does not have it. The fallback then sent back a
null procname and proctype, and discovery replaced the process.csv
entry with one named after the script (torq.q) and with no type, so
nothing could find the process by type afterwards.

That only happens when discovery reaches the process after it is
already listening, so it depends on start-up timing. The fallback now
sends .proc.procname and .proc.proctype, which every TorQ process sets
whether or not it loads the handlers.

Now with these changes we have KDB-X 632/632, L 632/632, PeachQ 552/632
and Korze 608/632. stp/tickerlog is 56/68 on PeachQ (before 34/68), and
Korze goes from 34/68 to 47/68.
merge/tplogreplay loaded treplaysettings.q, but the file is
tpreplaysettings.q, so its replays never ran partandmerge and the
temp-directory checks failed. With the right file the
checks still failed: they look at .replay.tempdir in the test process,
which kept the default instead of the directory the replay uses. The
test's settings now set it to that directory.

stp/idbdefault and stp/idbpartbyenum queried quote_iex through the
gateway to check that an unpublished table has no rows. The Starter
Pack schema no longer has quote_iex, so the gateway returned an error
string instead. They now query packets, which is in the schema and
which the tests never publish to.

stp/chainedeodlognone, chainedlogmodes and chainedrecovery left $write
out of their test command, so run.sh -w never wrote their results.
@jaen15marcos

Copy link
Copy Markdown
Contributor Author

Replaced by a series of smaller PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants