ClientOutOfLineExecutor is a decoration on Client, and it manages a MultiProducerSingleConsumerQueue to keep track of scheduled tasks. In its destructor method, ClientOutOfLineExecutor modifies the queue by closing its producer end and executing the scheduled task. The queue internally acquires and releases a lock to allow safe concurrent accesses. When testing diagnostics and tests commands are enabled, the queue would also run LatchAnalyzer methods (e.g., onAcquire) as part of accessing its internal mutex.
Since the destructor is invoked during the destruction of the Client object, and LatchAnalyzer also uses decorators (e.g., LatchSetState) to store Client metadata, running the destructor for ClientOutOfLineExecutor could potentially cause read-after-delete memory accesses.
To fix this issue, we should have an observer run the logic currently implemented by the destructor for ClientOutOfLineExecutor during Client destruction, to prevent the possibility for read-after-delete accesses.