Skip to content

fix(router): check outer event key in failuresMetric guard to prevent inner-map wipe - #7265

Open
harsh4vardhan wants to merge 1 commit into
rudderlabs:masterfrom
harsh4vardhan:fix/router-failures-metric-wrong-key
Open

fix(router): check outer event key in failuresMetric guard to prevent inner-map wipe#7265
harsh4vardhan wants to merge 1 commit into
rudderlabs:masterfrom
harsh4vardhan:fix/router-failures-metric-wrong-key

Conversation

@harsh4vardhan

Copy link
Copy Markdown

Summary

Resolves #7260.

The guard that initialises failuresMetric's inner map checks whether
the error string exists in the inner map, not whether the event
type
key exists in the outer map:

// Before (checks inner key — wrong)
if _, ok := rt.telemetry.failuresMetric[event][errorStr]; !ok {
    rt.telemetry.failuresMetric[event] = make(map[string]int)
}

Whenever a destination produces a second distinct error string within
one reporting window, the inner-map lookup returns false (the new
string isn't there yet), make() fires, and every count accumulated
so far for that event type is lost
. In a busy destination this resets
on every new error variant.

Fix

Check the outer event-type key so the inner map is initialised once
per event type and never overwritten:

if _, ok := rt.telemetry.failuresMetric[event]; !ok {
    rt.telemetry.failuresMetric[event] = make(map[string]int)
}

harsh4vardhan

…inner map

The guard condition that initializes the inner map of failuresMetric
checks whether the error-string key exists in the inner map rather
than whether the outer event-type key exists:

  if _, ok := rt.telemetry.failuresMetric[event][errorStr]; !ok {
      rt.telemetry.failuresMetric[event] = make(map[string]int)
  }

When a destination produces a second distinct error string the inner
map lookup returns false (the new string is not there yet), triggering
make() and wiping the entire inner map. Any previously accumulated
counts for that event type are lost. In a busy destination this
resets on every new error variant within a reporting window.

Fix: check the outer event-type key instead so the inner map is only
initialised once per event type.

Fixes rudderlabs#7260

Signed-off-by: harsh4vardhan <hvardhan609@gmail.com>
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.

router: failuresMetric inner map wiped on every new error string - wrong key checked in guard condition silently drops all prior failure counts

1 participant