arnoldasgudas / Hangfire.MySqlStorage

MySql storage for Hangfire - fire-and-forget, delayed and recurring tasks runner
GNU Lesser General Public License v3.0
174 stars 115 forks source link

Multiple fixes - pull request? #62

Open MiloszKrajewski opened 5 years ago

MiloszKrajewski commented 5 years ago

Hi,

I have multiple fixes related mostly to concurrency and table locking (it dies under pressure, dead-locking and/or leaking database connections). I raised some issues before (which I now fixed) but there was no reply. Do you accept Pull Request or this repository is dormant?

Regards,

arnoldasgudas commented 5 years ago

Hi Milosz, Yes, pull requests are accepted. Please raise one.

Thanks

MiloszKrajewski commented 5 years ago

It looks my change went so far that merge back would be very complicated.

The one thing worth emphasising is that TransactionScope (contrary to "regular" transactions) force use of MySQL distributed transactions which are not rolled back when connection dies. So unexpected shutdown on service causes transaction hanging forever and locking tables. When new service starts it begins to a) time out (locks) b) too many connections (as old ones are still open, they are just deadlocked).

See: https://www.percona.com/blog/2017/09/22/how-to-deal-with-xa-transactions-recovery/ also https://github.com/mysql-net/MySqlConnector/issues/254

Timovzl commented 5 years ago

The one thing worth emphasising is that TransactionScope (contrary to "regular" transactions) force use of MySQL distributed transactions which are not rolled back when connection dies.

That seems like an important issue!

The issue notwithstanding, in case this is helpful to you: If you wish to use TransactionScope but you still desire regular transactions rather than distributed transactions, you can use the connection string option UseXaTransactions=False.

I personally use this option all the time.