Skip to content

Fix streaming from TSDB#2900

Merged
jmthomas merged 8 commits intomainfrom
streaming
Mar 5, 2026
Merged

Fix streaming from TSDB#2900
jmthomas merged 8 commits intomainfrom
streaming

Conversation

@jmthomas
Copy link
Copy Markdown
Member

Replace UNION ALL with per-table k-way merge for TSDB streaming

Rewrite stream_items to query each table independently and merge results
by timestamp, avoiding JOIN issues with multi-table queries. Add
multi-table integration tests covering interleaved merges, CMD+TLM
mixing, table filtering, cross-table timestamps, batch boundaries, and
multi-item streaming. Fix before(:suite) QuestDB availability check.

jmthomas and others added 2 commits February 28, 2026 14:16
Replace ASOF JOIN with UNION ALL + ORDER BY for querying multiple
command/telemetry tables in Data Extractor. ASOF JOIN only returned
rows from T0 (losing other tables' data) and SPLICE JOIN cannot chain
3+ tables. UNION ALL queries each table independently with positional
NULLs for other tables' columns, then sorts by timestamp.

Also adds tsdb_table_has_data? helper to filter non-existent tables
and scopes calculated timestamp items to the row's source table so
the frontend correctly identifies the packet name.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Rewrite stream_items to query each table independently and merge results
by timestamp, avoiding JOIN issues with multi-table queries. Add
multi-table integration tests covering interleaved merges, CMD+TLM
mixing, table filtering, cross-table timestamps, batch boundaries, and
multi-item streaming. Fix before(:suite) QuestDB availability check.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@jmthomas jmthomas requested review from clayandgen and ryanmelt March 1, 2026 00:00
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 1, 2026

Codecov Report

❌ Patch coverage is 56.54596% with 156 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.31%. Comparing base (f9d0650) to head (e6c4bd7).
⚠️ Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
...-cmd-tlm-api/app/models/logged_streaming_thread.rb 67.60% 92 Missing ⚠️
openc3/lib/openc3/models/cvt_model.rb 0.00% 50 Missing ⚠️
openc3/lib/openc3/utilities/questdb_client.rb 33.33% 12 Missing ⚠️
...smos-cmd-tlm-api/app/controllers/api_controller.rb 50.00% 1 Missing ⚠️
...-cosmos-cmd-tlm-api/app/models/streaming_thread.rb 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2900      +/-   ##
==========================================
+ Coverage   78.28%   78.31%   +0.03%     
==========================================
  Files         673      673              
  Lines       55204    55196       -8     
  Branches      728      728              
==========================================
+ Hits        43216    43227      +11     
+ Misses      11910    11891      -19     
  Partials       78       78              
Flag Coverage Δ
python 79.31% <ø> (-0.01%) ⬇️
ruby-api 80.63% <67.69%> (+0.52%) ⬆️
ruby-backend 82.14% <8.82%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@ryanmelt ryanmelt left a comment

Choose a reason for hiding this comment

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

Can you move all uses of creating TSDB connections into the QuestDBClient helper file? That will make sharding it much easier, and consolidate all the TSDB stuff together into one file better.

# Returns true if the given TSDB table exists and has at least one row in the
# time range. Tables that have never received data don't exist in QuestDB.
def tsdb_table_has_data?(table_name, start_time, end_time)
query = "SELECT 1 FROM #{table_name}"
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.

Potential SQL injection via string-based query concatenation - high severity
SQL injection might be possible in these locations, especially if the strings being concatenated are controlled via user input.

Show fix

Remediation: If possible, rebuild the query to use prepared statements or an ORM. If that is not possible, make sure the user input is allowlisted or sanitized. As an added layer of protection, we also recommend installing a WAF that blocks SQL injection attacks.

Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 4, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
5.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@jmthomas jmthomas merged commit 8cf8ff3 into main Mar 5, 2026
48 of 53 checks passed
@jmthomas jmthomas deleted the streaming branch March 5, 2026 00:30
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