• Kirill Smelkov's avatar
    tracing/tracetest: Prevent deadlocks when there are extra events not consumed by main checker · 3b19f68c
    Kirill Smelkov authored
    A deadlock scenario was possible before this patch:
    
    - main thread finished checks, wants to return, goes to deferred wg.Wait();
    - that wg.Wait waits for other spawned threads to complete;
    - in one of that thread there is extra event being sent to a stream;
    - that send is blocked waiting for main thread to receive it, but the
      main thread is waiting in wg.Wait() and only after that it would go to
      call T.closeStreamTab() which marks all the channels as down -> deadlock.
    
    -> Fix it by explicitly detecting deadlocks not only in Recv, but also on Send.
    
    NOTE Contrary to Recv - which is always called from main thread - Send is
    always called from non-main threads. T.unsentv and the logic prepared in
    the previous patch care to handle that correctly.
    3b19f68c
example_test.go 9.43 KB