feat(analytics): expose write/read transaction queue depth (count) metrics#1689
Open
kriszyp wants to merge 2 commits into
Open
feat(analytics): expose write/read transaction queue depth (count) metrics#1689kriszyp wants to merge 2 commits into
kriszyp wants to merge 2 commits into
Conversation
…trics Secondary/supplementary metric for #592 (the primary leading indicator ships separately as the transaction-commit-time latency distribution). Emits write-transaction-queue-depth and read-transaction-queue-depth through the analytics pipeline as a per-thread concurrency signal. Write depth counts in-flight write commits (handed to the storage engine but not yet resolved); read depth is the count of open read-snapshot transactions (trackedTxns). Each gauge reports both the instantaneous depth and a per-sampling-window high-water mark, since the queue can fill and drain within a single (~1s) analytics period. Caveat (see PR description): a per-thread count does not capture transaction size/duration or the shared storage-engine write path, so latency (transaction-commit-time) is the better predictor of the overload error; this count is complementary (which worker is submitting more), not the primary signal. Relates to #592 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 7, 2026
Contributor
|
Reviewed; no blockers found. |
… hardening - Skip both queue-depth assertions under HARPER_STORAGE_ENGINE=lmdb: LMDB writes/reads route through the separate LMDBTransaction overrides (resources/LMDBTransaction.ts), which maintain their own unrelated trackedTxns set and do not feed this accounting -- matching the existing RocksDB-only carve-outs in transaction.test.js. This is what failed CI (all 3 Node versions, via the npm run test:unit:all -> test:unit:lmdb pass). - leaveWriteQueue() floors at zero, per Gemini review feedback -- cheap insurance against a future call-site imbalance corrupting every subsequent sample. - Guard commitResolution as thenable before calling .then(), per Gemini review feedback -- defensive against a future caller passing a non-Promise value (today's only caller, rocksdb-js's async Transaction.commit(), always returns a real Promise). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
write-transaction-queue-depthandread-transaction-queue-depthgauges (instantaneousdepth+ per-sampling-windowmaxDepthhigh-water mark) through the analytics pipeline. Write depth counts write commits handed to the storage engine but not yet resolved; read depth counts open read-snapshot transactions (trackedTxns).Purpose
Secondary/optional to #592. The primary leading indicator for the queue-overload 503 ships separately in #1688 (
transaction-commit-time, a latency distribution measured on the same clock the overload check uses).Open question for the reviewer — is this metric worth shipping at all? A per-thread count doesn't capture transaction size/duration, and each thread's queue is local while the real bottleneck is the shared storage-engine write path — so count can tell you which thread is submitting more, but not how close the system is to the 503. Kris raised this tradeoff; #1688 is the metric he considers the better predictor. This PR is offered as a complementary, cheap signal (concurrency-by-thread), not a replacement — happy to close it if the added surface area (2 more metric names,
getTransactionQueueDepthscall every sampling period) isn't judged worth it standalone.Attention
Generated by Claude Opus 4.8.