Skip to content

objectpool: Fix data race with logger

Patrick Steinhardt requested to merge pks-objectpool-fix-logging-data-race into master

In our test to verify that we correctly collect objectpool statistics via the logger, we create our own logger with a backing buffer. This buffer is being accessed concurrently though, once by the gRPC middleware which tries to write into it and once from the test itself after the RPC call has finished to verify it contains what we expect it to contain. Given that we don't use locking for this the result is a data race.

Fix the data race by locking the buffer when writing to or reading from it. Given that the RPC call has already finished at the time where we're reading from it and only gRPC middleware may continue to write to it, we know that the statistics we care about must already have been logged.

Fixes #3914 (closed)

Edited by Patrick Steinhardt

Merge request reports