adding trigram extension and indices #2499
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2499
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2499/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #2048
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2048
Original created: 2025-12-03T06:00:17Z
Original updated: 2025-12-03T06:08:29Z
Original head: carverauto/serviceradar:2047-chorecnpg-enable-pg_trgm
Original base: main
Original merged: 2025-12-03T06:08:25Z by @mfreeman451
User description
IMPORTANT: Please sign the Developer Certificate of Origin
Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Enhancement
Description
Enable pg_trgm PostgreSQL extension for trigram-based text search optimization
Create GIN indexes on unified_devices hostname and ip columns
Add database migration files for extension and index management
Document performance characteristics and implementation requirements
Diagram Walkthrough
File Walkthrough
proposal.md
Proposal for pg_trgm extension and trigram index implementationopenspec/changes/add-cnpg-pg-trgm-extension/proposal.md
with leading wildcards
unified_devices
significantly faster reads
spec.md
CNPG spec requirements for pg_trgm extension and indexesopenspec/changes/add-cnpg-pg-trgm-extension/specs/cnpg/spec.md
alongside TimescaleDB and Apache AGE
creation
EXPLAIN ANALYZE
indexes with down migration cleanup
tasks.md
Implementation tasks for pg_trgm extension rolloutopenspec/changes/add-cnpg-pg-trgm-extension/tasks.md
files
and ip columns
verification
indexing
00000000000016_pg_trgm_extension.up.sql
Migration to enable pg_trgm and create trigram indexespkg/db/cnpg/migrations/00000000000016_pg_trgm_extension.up.sql
lookup optimization
optimization
00000000000016_pg_trgm_extension.down.sql
Rollback migration for pg_trgm extension removalpkg/db/cnpg/migrations/00000000000016_pg_trgm_extension.down.sql
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2048#issuecomment-3605229903
Original created: 2025-12-03T06:01:20Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
No security concerns identified
No security vulnerabilities detected by AI analysis. Human verification advised for critical code.🎫 #2047
queries (including leading wildcards) avoid full table scans.
hostname; ip if applicable) with trigram indexes.
indexes.
Scan on the new trigram indexes in real environments.
extensions in deployed clusters.
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status: Passed
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status: Passed
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
Missing audit logs: The migration enables an extension and creates indexes without any accompanying audit
logging or recorded context of who performed these critical database changes.
Referred Code
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
No failure handling: SQL migration statements execute without explicit error handling or safeguards for
concurrent environments beyond IF NOT EXISTS, which may require additional operational
handling not visible in the diff.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2048#issuecomment-3605231940
Original created: 2025-12-03T06:02:10Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Fix migration failure in transactions
Remove the
CONCURRENTLYkeyword fromCREATE INDEXstatements to preventmigration failures within transaction blocks, or configure the migration runner
to execute this migration outside a transaction.
pkg/db/cnpg/migrations/00000000000016_pg_trgm_extension.up.sql [10-15]
Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies a critical issue where
CREATE INDEX CONCURRENTLYwill fail inside a transaction block, which is a common default for migration tools, thus preventing the migration from succeeding.