Skip to content

Fix race condition in io::Stats

Florian Schmaus requested to merge flow/emper:fix-io-stats into master

The workerStats std::vector was modified concurrently without being synchronized. The Stats are constructed together with IoContext and the worker IoContexts are constructed concurrently at the beginning of the worker loop. And in the Stats constructor the workerStats std::vector was modified by adding the Stats instance that is currently being constructed to it.

Turns out, we don't need the workerStats data structure at all. We simply provide the global and worker IoContexts to io::Stats::printStats(). This results IMHO in a cleaner design of printStats() since there is no longer a data structure called workerStats, that in fact, not only holds the worker's stats. And while we at it, we rename io::Stats::printWorkerStats() to io::Stats::printsStats(), since it does, in fact, not only print the worker stats, but more or less all related worker stats.

Merge request reports