madelson/DistributedLock

Connections leak with SqlDistributedLockConnectionStrategy.Azure

zavalita1 opened this issue · 2 comments

SqlDistributedLock.Try aquired with Azure strategy creates instance of AzureSqlDistributedLock and invokes it's TryAquire/TryAquireAsync with no contextHandle argument thus opening a new connection using provided connectionString. However when the lock is released and component is disposed, connection opened by it is not disposed thus leading to a connecion leakage.

Since outside connection vs. opening new connection case is determined anyway by keeping "ownsKeepalive" field way to go could be passing an connection instance to the LockScope if connection is being opened and having it disposed together with LockScope instance.

Thanks for reporting @zavalita1. I am currently working on the next version of the library and I will incorporate a fix for this with that release.

This is fixed as of version 1.4