Repository navigation
Quality sweep (SQL queries) - #417
Merged
Merged
Conversation
- syslog_process_alerts(): compile all rules to condition-only SQL and evaluate every rule's count in one consolidated SUM(CASE) scan of syslog_incoming (one scan per cycle regardless of rule count); rules below threshold or with zero counts skip their record fetches - syslog_device_rule_sql(): qualify the correlated host column so the mute filter was not a tautology (dr.host = dr.host silently matched every staged record and suppressed all alerts) - Add message_digest char(32) to syslog/syslog_removed (fresh installs via CREATE, existing via syslog_ensure_message_digest_columns()), backfill bounded per poller run via syslog_backfill_message_digest(); archive, move, and replication paths write MD5(message) at ingest - Viewer: grouped queries and nav counts key on the digest with an IF(digest = '', MD5(message), digest) exactness fallback, degrading to the old message GROUP BY when the column does not exist yet - Bounded per-render host-name fetch (host_id IN instead of full table) - tests: MessageDigestGroupingTest source-shape coverage
syslog_ensure_table_structures() now calls syslog_ensure_message_digest_ columns(), which lives in the part of includes/schema.php the test deliberately does not eval, so the harness needs a stub like the other ensure_* helpers it already keeps out of scope.
CI enforces 100% patch coverage on changed lines. Commit 5c65781 added several paths that had no unit tests: * syslog_backfill_message_digest(): cover the empty-table, missing-column, completed-cursor, empty-digest and chunked-walk branches * syslog_get_alert_sql(..., condition_only=true): cover every switch arm and the invalid-JSON filter path * syslog_process_alerts() Phase 1: cover the consolidation pass and its guard for an unsupported rule type * syslog_replication_accept_central(): cover the message_digest spliced parameters when the central schema already has the column * syslog_message_digest_ready(): cover the cached false path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* syslog_process_alerts() Phase 2: add AlertPhase2BranchesTest driving the level-0 method-1 threshold branch (5128/5129), the host-level branch (5156/5160) and the method-0 zero-count fast path (5170/5171) end-to-end against stub fixtures * syslog_backfill_message_digest()/syslog_message_digest_ready(): split the positive and negative cache paths into separate Pest files (AlertPhase2Branches uses the same fixture layout as ThresholdEpisode) so the static-cache re-read at 5946 is measurable in isolation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…lTest CI runs every Pest test in one process, so the static cache inside syslog_message_digest_ready() is populated by whichever file runs first in alphabetical order. MessageDigestReadyTest already covers the false branch in isolation, so removing the truthy assertion here avoids order flakiness without losing coverage.
TheWitness
approved these changes
Oct 16, 2026
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.
This pull request introduces several important enhancements and optimizations to syslog archival, alert processing, and schema management. The main focus is on adding and utilizing a
message_digestcolumn (MD5 hash of the message) in archival tables, improving alert rule evaluation for better performance, and supporting schema migrations and compatibility.Digest column integration and schema migration:
message_digestcolumn insyslogandsyslog_removedtables, ensuring consistent grouping and lookup capabilities. [1] [2] [3] [4] [5] [6]syslog_message_digest_readyandsyslog_backfill_message_digesthelper functions to check for digest column readiness and backfill missing digests in existing rows in batches, supporting zero-downtime schema upgrades.Alert rule evaluation performance improvements:
SQL and maintenance logic improvements:
Alert rule SQL generation flexibility:
syslog_get_alert_sqlnow supports acondition_onlymode, returning only the WHERE clause and parameters for efficient bulk evaluation of multiple rules. [1] [2]These changes collectively improve syslog archival reliability, alert rule performance, and schema upgrade safety.