parfait icon indicating copy to clipboard operation
parfait copied to clipboard

Race condition causes metric updates to be lost

Open pwinckles opened this issue 1 year ago • 1 comments

If a metric is updated while QuiescentRegistryListener is restarting PcpMmvWriter due to a monitorable being added, then it's possible that the metric update will be lost. This can happen because the metric update calls PcpMmvWriter.updateMetric(), which immediately returns if started is false. When QuiescentRegistryListener restarts PcpMmvWriter, it first stops it, setting started to false, and then starts it again. PcpMmvWriter.start() iterates over all of the metric data, writing it again, prior to setting started to true. So, the race occurs if a metric is updated between the time the old value is rewritten in PcpMmvWriter.start() and the time started is set to true.

pwinckles avatar Nov 16 '24 19:11 pwinckles

Unfortunately, my prior PR only partially addressed the issue. The race condition still exists if a monitorable is updated before the writer is started again but after the monitorable has been re-added to the writer. I hope to get a PR up to fix this case tomorrow.

pwinckles avatar Feb 21 '25 02:02 pwinckles