I am considering using TVar to store some state in a web application (which can be recreated on reboot). However, the controversial aspects of TVar apply to me. It seems that a frequent short transaction can drive out long transactions, constantly interrupting them. In addition, since longer transactions continue to restart, this will increase the CPU load, which will further increase the length of these transactions. In the end, I feel that this can lead to the server becoming completely unresponsive.
Given this, I have the following questions:
(1) Can TVar (or another data type) use locks rather than simultaneous attempts / retries.
(2) Can TVar (or another data type) have some other competitive mechanism, that is, “allow transactions to start one second before another transaction starts”, or at least some of them guarantee the completion of transactions (i.e. a competing algorithm that prevents starvation for longer transactions).
Clinton
source share