Commit 6c6dc3ce authored by MozLando's avatar MozLando
Browse files

Merge #4674



4674: 1586881: Fix high error rate on glean.baseline.duration r=mdboom a=mdboom

There is a race condition in how the TimingManager is used here.
When stopping a timer, we dispatch a task to actually record the value in the
timespan, and only reset the TimingManager in that async task after the
recording, which requires I/O, is complete.

If the timespan is started in the meantime, an error will be recorded, rather
than safely starting a new timespan measurement.

This change could be considered on the principle (followed elsewhere), that
we do timing management and measurement synchronously, and only recording
asynchronously.



Co-authored-by: default avatarMichael Droettboom <mdboom@gmail.com>
parents cf633e98 46a54476
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -83,13 +83,13 @@ data class TimespanMetricType(
                @Suppress("EXPERIMENTAL_API_USAGE")
                Dispatchers.API.launch {
                    TimespansStorageEngine.set(this@TimespanMetricType, timeUnit, elapsedNanos)
                }
            }

            // Reset the timerId.
            timerId = null
        }
    }
        }
    }

    /**
     * Abort a previous [start] call. No error is recorded if no [start] was called.