Trigger logic: delta_input <= 0 OR delta_output <= 0 drops valid deltas
File: cake4/rd_cake/setup/db/8.090_add_radacct_triggers.sql
Triggers: manage_user_stats_after_insert (line 73–75), manage_user_stats_after_update (line 211–213)
Both triggers reject the row if either delta is non-positive:
IF delta_input <= 0 OR delta_output <= 0 THEN
LEAVE proc;
END IF;
Issue: if only one direction increased since the last recorded bucket (e.g. input grew but output didn't move on this particular INSERT/UPDATE), the entire row — including the legitimate delta — is discarded. Nothing gets written to user_stats for that tick.
Example:
- Previous cumulative totals in
user_stats: acctinputoctets=1000, acctoutputoctets=500
- New
radacct row: acctinputoctets=1500, acctoutputoctets=500
delta_input=500, delta_output=0
- Condition is true (
delta_output <= 0) → LEAVE proc → the 500-byte input delta is silently dropped and never recorded anywhere.
Over time this causes SUM(acctinputoctets) / SUM(acctoutputoctets) in user_stats to drift from the true cumulative counters in radacct, especially at session close where one counter often stalls on the final packet.
Question: Is the OR intentional (e.g. to only record "complete" bidirectional traffic ticks), or should this be AND so a row is only skipped when neither direction moved?
If it's a bug, happy to submit a PR changing the condition to:
IF delta_input <= 0 AND delta_output <= 0 THEN
LEAVE proc;
END IF;
Trigger logic:
delta_input <= 0 OR delta_output <= 0drops valid deltasFile:
cake4/rd_cake/setup/db/8.090_add_radacct_triggers.sqlTriggers:
manage_user_stats_after_insert(line 73–75),manage_user_stats_after_update(line 211–213)Both triggers reject the row if either delta is non-positive:
Issue: if only one direction increased since the last recorded bucket (e.g. input grew but output didn't move on this particular INSERT/UPDATE), the entire row — including the legitimate delta — is discarded. Nothing gets written to
user_statsfor that tick.Example:
user_stats:acctinputoctets=1000,acctoutputoctets=500radacctrow:acctinputoctets=1500,acctoutputoctets=500delta_input=500,delta_output=0delta_output <= 0) →LEAVE proc→ the 500-byte input delta is silently dropped and never recorded anywhere.Over time this causes
SUM(acctinputoctets)/SUM(acctoutputoctets)inuser_statsto drift from the true cumulative counters inradacct, especially at session close where one counter often stalls on the final packet.Question: Is the
ORintentional (e.g. to only record "complete" bidirectional traffic ticks), or should this beANDso a row is only skipped when neither direction moved?If it's a bug, happy to submit a PR changing the condition to: