beagle r4517 - in branches/beagle-lucene2_1/beagled/Lucene.Net: Store upstream-changes



Author: dbera
Date: Fri Feb 22 00:35:27 2008
New Revision: 4517
URL: http://svn.gnome.org/viewvc/beagle?rev=4517&view=rev

Log:
Add old patch 15_lock-timeout-verbose.patch


Added:
   branches/beagle-lucene2_1/beagled/Lucene.Net/upstream-changes/08_lock-timeout-verbose.patch
Modified:
   branches/beagle-lucene2_1/beagled/Lucene.Net/Store/Lock.cs
   branches/beagle-lucene2_1/beagled/Lucene.Net/Store/SimpleFSLockFactory.cs

Modified: branches/beagle-lucene2_1/beagled/Lucene.Net/Store/Lock.cs
==============================================================================
--- branches/beagle-lucene2_1/beagled/Lucene.Net/Store/Lock.cs	(original)
+++ branches/beagle-lucene2_1/beagled/Lucene.Net/Store/Lock.cs	Fri Feb 22 00:35:27 2008
@@ -65,25 +65,36 @@
 		public virtual bool Obtain(long lockWaitTimeout)
 		{
 			failureReason = null;
-			bool locked = Obtain();
 			int maxSleepCount = (int) (lockWaitTimeout / LOCK_POLL_INTERVAL);
 			int sleepCount = 0;
 			maxSleepCount = System.Math.Max (maxSleepCount, 1);
+			SimpleFSLock.Log ("Lock.Obtain timeout={0} maxsleepcount={1}", lockWaitTimeout, maxSleepCount);
+			bool locked = Obtain();
 			while (!locked)
 			{
 				if (sleepCount++ == maxSleepCount)
 				{
-					System.String reason = "Lock obtain timed out: " + this.ToString();
-					if (failureReason != null)
-					{
-						reason += (": " + failureReason);
-					}
-					System.IO.IOException e = new System.IO.IOException(reason);
-					if (failureReason != null)
-					{
-                        e = new System.IO.IOException(reason, failureReason);
+					// Try and be a little more verbose on failure
+					string lockpath = this.ToString ();
+					System.Text.StringBuilder ex = new System.Text.StringBuilder();
+					ex.Append ("Lock obtain timed out: ");
+					ex.Append (lockpath);
+					if (System.IO.File.Exists (lockpath)) {
+						System.IO.FileStream fs = System.IO.File.Open (lockpath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
+						System.IO.StreamReader sr = new System.IO.StreamReader (fs);
+						string pid = sr.ReadToEnd ().Trim ();
+						sr.Close ();
+						fs.Close ();
+						ex.Append (" -- pid ").Append (pid);
+
+						if (System.IO.Directory.Exists ("/proc/" + pid))
+							ex.Append (" -- process exists");
+						else
+							ex.Append (" -- process does not exist, stale lockfile?");
+					} else {
+						ex.Append (" -- lock file doesn't exist!?");
 					}
-					throw e;
+					throw new System.IO.IOException(ex.ToString ());
 				}
 				System.Threading.Thread.Sleep((int) LOCK_POLL_INTERVAL);
 				locked = Obtain();

Modified: branches/beagle-lucene2_1/beagled/Lucene.Net/Store/SimpleFSLockFactory.cs
==============================================================================
--- branches/beagle-lucene2_1/beagled/Lucene.Net/Store/SimpleFSLockFactory.cs	(original)
+++ branches/beagle-lucene2_1/beagled/Lucene.Net/Store/SimpleFSLockFactory.cs	Fri Feb 22 00:35:27 2008
@@ -253,7 +253,7 @@
 		
 		public override System.String ToString()
 		{
-			return "SimpleFSLock@" + lockFile;
+			return "SimpleFSLock@" + lockFile.FullName;
 		}
 		
 		static public Beagle.Util.Logger Logger = null;

Added: branches/beagle-lucene2_1/beagled/Lucene.Net/upstream-changes/08_lock-timeout-verbose.patch
==============================================================================
--- (empty file)
+++ branches/beagle-lucene2_1/beagled/Lucene.Net/upstream-changes/08_lock-timeout-verbose.patch	Fri Feb 22 00:35:27 2008
@@ -0,0 +1,70 @@
+From: Daniel Drake <dsd gentoo org>
+
+When lock obtain times out, do a little bit of automatic investigation into
+the possibly-stale lockfile.
+
+Index: Store/SimpleFSLockFactory.cs
+===================================================================
+--- Store/SimpleFSLockFactory.cs	(revision 4509)
++++ Store/SimpleFSLockFactory.cs	(working copy)
+@@ -253,7 +253,7 @@
+ 		
+ 		public override System.String ToString()
+ 		{
+-			return "SimpleFSLock@" + lockFile;
++			return "SimpleFSLock@" + lockFile.FullName;
+ 		}
+ 		
+ 		static public Beagle.Util.Logger Logger = null;
+Index: Store/Lock.cs
+===================================================================
+--- Store/Lock.cs	(revision 4516)
++++ Store/Lock.cs	(working copy)
+@@ -65,25 +65,36 @@
+ 		public virtual bool Obtain(long lockWaitTimeout)
+ 		{
+ 			failureReason = null;
+-			bool locked = Obtain();
+ 			int maxSleepCount = (int) (lockWaitTimeout / LOCK_POLL_INTERVAL);
+ 			int sleepCount = 0;
+ 			maxSleepCount = System.Math.Max (maxSleepCount, 1);
++			SimpleFSLock.Log ("Lock.Obtain timeout={0} maxsleepcount={1}", lockWaitTimeout, maxSleepCount);
++			bool locked = Obtain();
+ 			while (!locked)
+ 			{
+ 				if (sleepCount++ == maxSleepCount)
+ 				{
+-					System.String reason = "Lock obtain timed out: " + this.ToString();
+-					if (failureReason != null)
+-					{
+-						reason += (": " + failureReason);
++					// Try and be a little more verbose on failure
++					string lockpath = this.ToString ();
++					System.Text.StringBuilder ex = new System.Text.StringBuilder();
++					ex.Append ("Lock obtain timed out: ");
++					ex.Append (lockpath);
++					if (System.IO.File.Exists (lockpath)) {
++						System.IO.FileStream fs = System.IO.File.Open (lockpath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
++						System.IO.StreamReader sr = new System.IO.StreamReader (fs);
++						string pid = sr.ReadToEnd ().Trim ();
++						sr.Close ();
++						fs.Close ();
++						ex.Append (" -- pid ").Append (pid);
++
++						if (System.IO.Directory.Exists ("/proc/" + pid))
++							ex.Append (" -- process exists");
++						else
++							ex.Append (" -- process does not exist, stale lockfile?");
++					} else {
++						ex.Append (" -- lock file doesn't exist!?");
+ 					}
+-					System.IO.IOException e = new System.IO.IOException(reason);
+-					if (failureReason != null)
+-					{
+-                        e = new System.IO.IOException(reason, failureReason);
+-					}
+-					throw e;
++					throw new System.IO.IOException(ex.ToString ());
+ 				}
+ 				System.Threading.Thread.Sleep((int) LOCK_POLL_INTERVAL);
+ 				locked = Obtain();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]