private async ValueTask ReleaseAsync <TLockCookie>(IDbSynchronizationStrategy <TLockCookie> strategy, string name, TLockCookie lockCookie) where TLockCookie : class { using var _ = await this._mutex.AcquireAsync(CancellationToken.None).ConfigureAwait(false); try { await strategy.ReleaseAsync(this._connection, name, lockCookie).ConfigureAwait(false); } finally { if (this._heldLocksToKeepaliveCadences.TryGetValue(name, out var keepaliveCadence)) { this._heldLocksToKeepaliveCadences.Remove(name); if (!keepaliveCadence.IsInfinite) { // note: we do this even if we're about to close the connection because we'll want // the correct cadence set when and if we re-open this.SetKeepaliveCadenceNoLock(); } } await this.CloseConnectionIfNeededNoLockAsync().ConfigureAwait(false); } }