hist_backfill_fixes: working-around (some) conc issues in the tsdb backfiller #62
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "hist_backfill_fixes"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
A bunch of first-draft implementation and reorg work around some long lingering backfiller bugs/issues which seem to have been introduced as part of moving to our
.parquet-file backed default/builting tsdb per, colloquially dubbednativedb.I haven’t gone into much detail here about the fairly large set of changes since the explanation(s) will come in the follow up #75. We are landing this now since there are some subtle backfiller fixes which seem to resolve the most obvious issues (using mostly workarounds for now, unfortunately).
The very quick hi-level splanation is,
.tsp.__init__content ->.tsp._history.ui._remote_ctl) for charts to include morepyqtgraph-graphics-type parameter passing and more endpoints to support all of arrows, txt-labels and rects..ui._editors.ArrowEditoras needed..data._sharedmemAPI for offline usage from non-owning, non-actor script processes..storage.cli.markup_gaps()-> new.tsp._annotate..tsp._annotate.humanize_duration()for time-gap txt labeling content..tsp._dedupe_smart(written byclaudebased on my heuristic-logic) to better de-duplicate real-time written bars versus differing versions from provider history..ui._style.get_fonts()for retrieving the dpi-aware instances.claudewrote for itself to be able to grok a human dev’s experience introspecting crashes frompdb.pexpectas a dev dep.xonshrelease for @goodboy’s prompt injection needs.Before landing,
piker.tsp._historysubsys (and friends) namely for,piker store delete <fqme>)piker store ls) where bothpiker chartandpikerdwere cancelled “gracefully” (using the normal ctl-c from console) and/or when the host lost it’s network connection/crashed/was-purposely-killed by the sys (say using `kill -SIGKILL $(pgrep -f pikerd).In follow through,
Follow-up-todos from GH,
-> also now moved to #75
79eb8a1684tod147bfe8c4Add a new `snippets/claude_debug_helper.py` to provide a programmatic interface to `tractor.pause()` debugger sessions for incremental data inspection matching the interactive UX but able to be run by `claude` "offline" since it can't seem to feed stdin (so it claims) to the `pdb` instance due to lack of ability to allocate a tty internally. The script-wrapper is based on `tractor`'s `tests/devx/` suite's use of `pexpect` patterns for driving `pdbp` prompts and thus enables automated-offline execution of REPL-inspection commands **without** using incremental-realtime output capture (like a human would use it). Features: - `run_pdb_commands()`: batch command execution - `InteractivePdbSession`: context manager for step-by-step REPL interaction - `expect()` wrapper: timeout handling with buffer display - Proper stdin/stdout handling via `pexpect.spawn()` Example usage: ```python from debug_helper import InteractivePdbSession with InteractivePdbSession( cmd='piker store ldshm zecusdt.usdtm.perp.binance' ) as session: session.run('deduped.shape') session.run('step_gaps.shape') ``` (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codeNamely such that when the previous-df-row by our shm-abs-'index' doesn't exist we ignore certain cases which are likely due to borked-but-benign samples written to the tsdb or rt shm buffers prior. Particularly we now ignore, - any `dt`/`prev_dt` values which are UNIX-epoch timestamped (val of 0). - any row-is-first-row in the df; there is no previous. - any missing previous datum by 'index', in which case we lookup the `wdts` prior row and use that instead. * this would indicate a missing sample for the time-step but we can still detect a "gap" by looking at the prior row, by df-abs-index `i`, and use its timestamp to determine the period/size of missing samples (which need to likely still be retrieved). * in this case i'm leaving in a pause-point for introspecting these rarer cases when `--pdb` is passed via CLI. Relatedly in the `piker store` CLI ep, - add `--pdb` flag to `piker store`, pass it verbatim as `debug_mode`. - when `times` has only a single row, don't calc a `period_s` median. - only trace `null_segs` when in debug mode. - always markup/dedupe gaps for `period_s==60`9ebb977731tocd6bc105deChange annot-ctl APIs to return `None` on failure instead of invalid `aid`s. Server now sends `{'error': msg}` dict on failures, client match-blocks handle gracefully. Also, - update return types: `.add_rect()`, `.add_arrow()`, `.add_text()` now return `int|None` - match on `{'error': str(msg)}` in client IPC receive blocks - send error dicts from server on timestamp lookup failures - add failure handling in `markup_gaps()` to skip bad rects (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codee937b60ed6to62e9c74377hist_backfill_fixes: solving conc issues in the tsdb backfillerto WIP: hist_backfill_fixes: solving conc issues in the tsdb backfillerWIP: hist_backfill_fixes: solving conc issues in the tsdb backfillerto hist_backfill_fixes: solving conc issues in the tsdb backfiller62e9c74377toa97f6c8dcf-> I think this one was expected, so i used github link.
Caused by: Distribution not found at: file:///home/momo/Downloads/tractor
-> also with this command i got some warnings for tractor: piker store ls . expected warnings. [piker]$ piker store ls btcusdt.spot.binance btc.usdtm.perp.binance
-> piker store delete btcusdt.spot.binance
[piker]$ piker store delete btcusdt.spot.binance ->Then when did this: piker chart btcusdt.spot.binance there was no time gaps.
-> ctrl c and [piker]$ kill -9 $(pgrep -f “piker chart”) both worked, i had this: [10] > /home/momo/Downloads/piker/piker/tsp/_history.py(209)maybe_fill_null_segments() -> import greenback (Pdb+)
i dont know if i forgot to install dev dependencies, or the gap detection logic found actual gaps and triggered the fill routine (which needs greenback) , it comes from : maybe_fill_null_segments() )
Yup.. i just put up a commit to fix.. 🤦
I also just added
'repl'to the default deps groups in that last commit which should hopefully resolve this.Yeah I just did one more round of testing on both ib and binance and i think landing this definitely doesn’t make things worse XD
I’m going to finish/move a couple of the bullets above and then land this puppy.
@ -0,0 +1,306 @@# piker: trading gear for hackersAhh yeah, prolly worth noting that though it’s not documented yet, this is a a new
.tspmod which provides a bunch of new functionality for annotating time-gaps via a remote API started a while back when i first started digging into time-gap issues in the backfiller during thenativedbfirst-draft.I’m not going to go through everything in detail here since it’s all going to be much more refined and formalized in #75 (and follow up).
@ -0,0 +1,256 @@#!/usr/bin/env pythonAhh right and this is an “offline REPL runner” script
claudewrote for itself to be able to grok a human dev’s experience introspecting crashes frompdbsince apparently it can’t actually allow TTY takeover by such tools (and/or can’t sub-spawn one inside it’s process tree..)This prolly should be better refined as well once we have
claudemore integrated in our workflow.@ -28,1435 +28,25 @@ Historical TSP (time-series processing) lowlevel mgmt machinery and biz logic fostored offline (in a tsdb).'''from __future__ import annotationsNote this large change is just moving content to a new
.tsp._history.@ -0,0 +10,4 @@from ._anal import with_dtsdef dedupe_ohlcv_smart(Using a heuristic for which bar(s) are likely most correct given known race conditions around OHLCV sampling under real-time-write usage.
hist_backfill_fixes: solving conc issues in the tsdb backfillerto hist_backfill_fixes: working-around (some) conc issues in the tsdb backfiller@ -194,0 +198,4 @@# to get fancy next-cmd/suggestion feats prior to 0.22.2 B)# https://github.com/xonsh/xonsh/pull/6037# https://github.com/xonsh/xonsh/pull/6048xonsh = { git = 'https://github.com/xonsh/xonsh.git', branch = 'main' }hmm, could prolly just pin this to latest release here?
yup did it.