mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-06-25 11:38:49 +03:00
Previously, NewChild elements of querytracer could be referenced by concurrent storageNode goroutines. After earlier return ( if search.skipSlowReplicas is set), it is possible, that tracer objects could be still in-use by concurrent workers. It may cause panics and data races. Most probable case is when parent tracer is finished, but children still could write data to itself via Donef() method. It triggers read-write data race at trace formatting. This commit adds a new methods to the querytracer package, that allows to create children not referenced by parent and add it to the parent later. Orphaned child must be registered at the parent, when goroutine returns. It's done synchronously by the single caller via finishQueryTracer call. If child didn't finished work and reference for it is used by concurrent goroutine, new child must be created instead with context message. It prevents panics and possible data races. Related issue: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/8114 --------- Signed-off-by: f41gh7 <nik@victoriametrics.com> Co-authored-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> Co-authored-by: Roman Khavronenko <roman@victoriametrics.com>