Tracksolid deployment with timescale & grafana with backup
Find a file
David Kiania 8867be9d3d
Some checks are pending
Static Analysis / static (push) Waiting to run
Tests / test (push) Waiting to run
perf+fix: SAVEPOINT-per-item pollers, batched GPS inserts, parallel detail fetch
Audit fixes across the ingestion stack:

Observability
- Move log_ingestion out of batch loops in poll_alarms and poll_parking
  (was emitting N cumulative log rows per run instead of one).
- Add missing log_ingestion + t0 to poll_trips.
- Count inserted via cur.rowcount instead of naive +=1 so ON CONFLICT
  DO NOTHING no longer inflates the metric.

Resilience
- SAVEPOINT-per-item added to poll_alarms, poll_live_positions,
  poll_trips, poll_parking so one bad row no longer aborts the batch
  (webhook handlers already had this; pollers were inconsistent).

Performance
- /pushgps and poll_track_list now use psycopg2.extras.execute_values
  with ON CONFLICT DO NOTHING — 10-50x write throughput on larger
  batches.
- sync_devices and sync_driver_audit fetch jimi.track.device.detail
  concurrently via ThreadPoolExecutor(max_workers=8), cutting the
  daily registry sync from ~24s to ~3s for an 80-device fleet.
- poll_track_list split into two phases: parallel API fetch (4 workers,
  no DB connection held) then one batched write. Previously the DB
  connection was held across every per-IMEI HTTP call, risking pool
  starvation.

Security
- _validate_token uses hmac.compare_digest for constant-time token
  comparison (closes timing side-channel).
- _parse_data_list caps incoming items at WEBHOOK_MAX_ITEMS (default
  5000) so a pathological push cannot blow memory.

Tests
- Fix test_null_alarm_type_skipped: its INSERT-count assertion was
  catching the ingestion_log insert written by log_ingestion. Filter
  that out so the test checks only data-table inserts.
- Full suite: 66 passed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 00:33:55 +03:00
.forgejo/workflows feat: add db_audit health checks, runner, and scheduled Forgejo workflow 2026-04-12 21:40:29 +03:00
administration Add DB connection string to ops manual, add administration notes, remove stale deploy guide 2026-04-10 22:34:56 +03:00
db_audit feat: add db_audit health checks, runner, and scheduled Forgejo workflow 2026-04-12 21:40:29 +03:00
docs docs: add quality program design spec 2026-04-12 21:31:56 +03:00
grafana Fix Grafana provisioning: bake datasource/dashboard config into custom image 2026-04-11 22:18:44 +03:00
n8n-workflows Add n8n workflow templates and change webhook port to 8888 2026-04-08 18:54:42 +03:00
tests perf+fix: SAVEPOINT-per-item pollers, batched GPS inserts, parallel detail fetch 2026-04-18 00:33:55 +03:00
.env Fix Grafana datasource: add GRAFANA_DB_RO_PASSWORD and sync grafana_ro on startup 2026-04-11 19:22:30 +03:00
.gitignore Add webhook receiver, consolidate shared utilities, expand telemetry coverage 2026-04-08 16:31:17 +03:00
.python-version chore: align .python-version to 3.12.0 (matches Docker image and pyproject.toml) 2026-04-12 21:41:43 +03:00
01_BusinessAnalytics.md Replace hardcoded container names with dynamic lookup 2026-04-10 23:09:01 +03:00
02_tracksolid_docker_commands.md Add 02_tracksolid_docker_commands.md — remote DB command reference 2026-04-11 08:23:01 +03:00
02_tracksolid_full_schema_rev.sql Add webhook receiver, consolidate shared utilities, expand telemetry coverage 2026-04-08 16:31:17 +03:00
03_webhook_schema_migration.sql Add webhook receiver, consolidate shared utilities, expand telemetry coverage 2026-04-08 16:31:17 +03:00
04_bug_fix_migration.sql Fix alarm field mapping, distance unit bug, parking params; add schema migrations 2026-04-10 22:18:30 +03:00
05_enhancement_migration.sql Fix alarm field mapping, distance unit bug, parking params; add schema migrations 2026-04-10 22:18:30 +03:00
260410_baseline_report.md Regenerate 260410_baseline_report.md from live database (post-migration) 2026-04-11 07:42:33 +03:00
260412_baseline_report.md Add 260412 baseline report — first trip data, FIX-M16 confirmed 2026-04-12 00:14:27 +03:00
CLAUDE.md Add CLAUDE.md and project docs for structured Claude project 2026-04-12 20:59:15 +03:00
docker-compose.yaml Fix Grafana provisioning: bake datasource/dashboard config into custom image 2026-04-11 22:18:44 +03:00
Dockerfile Fix migration failures: switch to full TimescaleDB + use psql runner 2026-04-08 17:17:58 +03:00
grafanaDeployment.md Add Grafana NOC fleet dashboard with provisioning 2026-04-09 00:01:52 +03:00
grafanaOperationalManual.md Add Grafana NOC operational manual 2026-04-09 00:12:48 +03:00
ingest_events_rev.py perf+fix: SAVEPOINT-per-item pollers, batched GPS inserts, parallel detail fetch 2026-04-18 00:33:55 +03:00
ingest_movement_rev.py perf+fix: SAVEPOINT-per-item pollers, batched GPS inserts, parallel detail fetch 2026-04-18 00:33:55 +03:00
OPERATIONS_MANUAL.md Replace hardcoded container names with dynamic lookup 2026-04-10 23:09:01 +03:00
pyproject.toml ci: add ruff + mypy static analysis config and Forgejo workflow 2026-04-12 21:32:33 +03:00
README.md first commit 2026-04-07 20:41:16 +03:00
run_migrations.py Fix Grafana datasource: add GRAFANA_DB_RO_PASSWORD and sync grafana_ro on startup 2026-04-11 19:22:30 +03:00
run_migrations.sh Add idempotent migration runner script 2026-04-10 23:31:57 +03:00
sync_driver_audit.py perf+fix: SAVEPOINT-per-item pollers, batched GPS inserts, parallel detail fetch 2026-04-18 00:33:55 +03:00
tracksolid_DB_manual.md Replace hardcoded container names with dynamic lookup 2026-04-10 23:09:01 +03:00
tracksolidApiDocumentation.md Update tracksolidApiDocumentation.md with live implementation findings 2026-04-11 07:52:28 +03:00
ts_shared_rev.py Fix 5 webhook bugs: SAVEPOINTs, NULL guards, BCD timestamps, /pushevent, log NULL fix 2026-04-11 18:19:13 +03:00
webhook_receiver_rev.py perf+fix: SAVEPOINT-per-item pollers, batched GPS inserts, parallel detail fetch 2026-04-18 00:33:55 +03:00