Skip to content
This repository
Browse code

Make sure that delayed node failures do not overwrite internal state.

  • Loading branch information...
commit b5c9e0981f7d44f86127693c87b7b55fbb5f12e9 1 parent 37607e0
Attila Kiskó authored July 18, 2011

Showing 1 changed file with 8 additions and 4 deletions. Show diff stats Hide diff stats

  1. 12  Membase/MembasePool.cs
12  Membase/MembasePool.cs
@@ -242,10 +242,10 @@ void IDisposable.Dispose()
242 242
 		{
243 243
 			GC.SuppressFinalize(this);
244 244
 
245  
-			if (this.state != null)
  245
+			if (this.state != null && this.state != InternalState.Empty)
246 246
 				lock (this.DeadSync)
247 247
 				{
248  
-					if (this.state != null)
  248
+					if (this.state != null && this.state != InternalState.Empty)
249 249
 					{
250 250
 						var currentNodes = this.state.CurrentNodes;
251 251
 						this.state = null;
@@ -269,7 +269,7 @@ void IDisposable.Dispose()
269 269
 
270 270
 		private void rezCallback(object o)
271 271
 		{
272  
-			if (this.state == null) return;
  272
+			if (this.state == null || this.state == InternalState.Empty) return;
273 273
 
274 274
 			var isDebug = log.IsDebugEnabled;
275 275
 
@@ -291,7 +291,7 @@ private void rezCallback(object o)
291 291
 			// 8. GOTO 2
292 292
 			lock (this.DeadSync)
293 293
 			{
294  
-				if (this.state == null) return;
  294
+				if (this.state == null || this.state == InternalState.Empty) return;
295 295
 
296 296
 				var currentState = this.state;
297 297
 				var nodes = currentState.CurrentNodes;
@@ -359,6 +359,10 @@ private void NodeFail(IMemcachedNode node)
359 359
 			{
360 360
 				var currentState = this.state;
361 361
 
  362
+				// the pool has been already reinitialized by the time the node
  363
+				// reported its failure, thus it has no connection to the current state
  364
+				if (currentState == null || currentState == InternalState.Empty) return;
  365
+
362 366
 				// we don't know who to reconfigure the pool when vbucket is
363 367
 				// enabled, so operations targeting the dead servers will fail.
364 368
 				// when we have a normal config we just reconfigure the locator,

0 notes on commit b5c9e09

Please sign in to comment.
Something went wrong with that request. Please try again.