According to the documentation, using addFinalizer on an "ordinary non-primitive Haskell type" may cause the finalizer to run earlier than expected, due to the compiler being "free to optimise away or duplicate the underlying data structure".
This is reproducibly happening in our code, which uses resource-pool in snap-based web applications (both directly and transitively eg. by using hedis). The result is that the reaper thread gets killed immediately and idle resources never get freed.
I haven't been able to track down why exactly this is happening only in this context (using resource-pool "standalone" seems to work fine), but the attached patch fixes the issue.
According to the documentation, using
addFinalizer
on an "ordinary non-primitive Haskell type" may cause the finalizer to run earlier than expected, due to the compiler being "free to optimise away or duplicate the underlying data structure".This is reproducibly happening in our code, which uses
resource-pool
insnap
-based web applications (both directly and transitively eg. by using hedis). The result is that thereaper
thread gets killed immediately and idle resources never get freed.I haven't been able to track down why exactly this is happening only in this context (using
resource-pool
"standalone" seems to work fine), but the attached patch fixes the issue.