input-output-hk/iohk-monitoring-framework

withTrace sometimes fails to close the trace

deepfire opened this issue · 2 comments

There is some evidence that in certain cases withTrace may fail to run its closing side:
https://github.com/input-output-hk/iohk-monitoring-framework/blob/master/iohk-monitoring/src/Cardano/BM/Setup.lhs#L75

This is evident in the routing tests -- as modified by 323da4a -- the closing side is never called:

Closing side:
323da4a#diff-994d687fdff98f853d46887653be7953R147

Output:

  Routing tests
    Unit tests
      default_scribe_must_log:                                            setSetupScribes
withTrace
within Trace
without Trace -> readFile
FAIL
        Exception: out-test.txt: openFile: resource busy (file is locked)
      set_backend_must_log:                                               setSetupScribes
withTrace
error while opening log: out-test.txt
exception: out-test.txt: openFile: resource busy (file is locked)
within Trace
without Trace -> readFile
setSetupScribes
withTrace
FAIL
        Exception: out-test.txt: openFile: resource busy (file is locked)
      set_scribe_must_log:                                                error while opening log: out-test.txt
exception: out-test.txt: openFile: resource busy (file is locked)
within Trace
without Trace -> readFile
setSetupScribes
withTrace
FAIL
        Exception: out-test.txt: openFile: resource busy (file is locked)
      set_scribe_with_wrong_filename_must_not_log:                        error while opening log: out-test.txt
exception: out-test.txt: openFile: resource busy (file is locked)
within Trace
without Trace -> readFile
setSetupScribes
withTrace
FAIL
        Exception: out-test.txt: openFile: resource busy (file is locked)
      no_scribe_must_not_log:                                             error while opening log: out-test.txt
exception: out-test.txt: openFile: resource busy (file is locked)
within Trace
without Trace -> readFile
FAIL
        Exception: out-test.txt: openFile: resource busy (file is locked)
  Testing Structured Logging

The modified test with traces is at https://github.com/input-output-hk/iohk-monitoring-framework/blob/489-withTrace-infelicity-repro/iohk-monitoring/test/Cardano/BM/Test/Routing.lhs#L129

This doesn't occur with #493

@CodiePP, I have a suspicion that this still might potentially be a problem..

This started to appear after I switched the STM queue to unagi-chan -- which I think I did properly.