Permalink
Browse files

NCBC-228: Frequent pooled socket errors during rebalance

It appears that there are concurrency issues when the server
is sending frequent config updates, as is the case during
a rebalance.  Config updates trigger the client to destroy its
socket pool after first creating a new one.

This change briefly delays the destruction of the old pool
so that any in progress operations may complete.
  • Loading branch information...
1 parent e3c4fa2 commit f124430afba7f1841f274139376046c5bfaae50b @johnzablocki johnzablocki committed Feb 19, 2013
Showing with 17 additions and 15 deletions.
  1. +17 −15 Enyim.Caching/Memcached/MemcachedNode.cs
@@ -479,24 +479,26 @@ public void Dispose()
// if someone uses a pooled item then 99% that an exception will be thrown
// somewhere. But since the dispose is mostly used when everyone else is finished
// this should not kill any kittens
- if (!this.isDisposed)
- {
- this.isAlive = false;
- this.isDisposed = true;
+ new Timer((s) => {
+ if (!this.isDisposed)
+ {
+ this.isAlive = false;
+ this.isDisposed = true;
- PooledSocket ps;
+ PooledSocket ps;
- while (this.freeItems.TryPop(out ps))
- {
- try { ps.Destroy(); }
- catch { }
- }
+ while (this.freeItems.TryPop(out ps))
+ {
+ try { ps.Destroy(); }
+ catch { }
+ }
- this.ownerNode = null;
- this.semaphore.Close();
- this.semaphore = null;
- this.freeItems = null;
- }
+ this.ownerNode = null;
+ this.semaphore.Close();
+ this.semaphore = null;
+ this.freeItems = null;
+ }
+ }, null, 1000, Timeout.Infinite);
}
void IDisposable.Dispose()

0 comments on commit f124430

Please sign in to comment.