Remove useless logging of a bare-names stack trace. It's meaningless

to a non-programmer and insufficient for a programmer.
Add commented debug output and data collection to troubleshoot
future locking issues.
avinationmerge
Melanie 2012-06-06 20:37:29 +02:00
parent 67483a6e50
commit a12336390f
1 changed files with 57 additions and 32 deletions

View File

@ -52,10 +52,10 @@ namespace OpenSim.Framework
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Thread LockedByThread; private Thread LockedByThread;
private string WriterStack; // private string WriterStack;
private Dictionary<Thread, string> ReadLockers = // private Dictionary<Thread, string> ReadLockers =
new Dictionary<Thread, string>(); // new Dictionary<Thread, string>();
/// <value> /// <value>
/// An advanced lock for inventory data /// An advanced lock for inventory data
@ -98,14 +98,25 @@ namespace OpenSim.Framework
m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
try try
{ {
StackTrace stackTrace = new StackTrace(); // get call stack // That call stack is useful for end users only. RealProgrammers need a full dump. Commented.
StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) // StackTrace stackTrace = new StackTrace(); // get call stack
// StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)
//
// // write call stack method names
// foreach (StackFrame stackFrame in stackFrames)
// {
// m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name)); // write method name
// }
// write call stack method names // The below is far more useful
foreach (StackFrame stackFrame in stackFrames) // System.Console.WriteLine("------------------------------------------");
{ // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name)); // write method name // System.Console.WriteLine("------------------------------------------");
} // foreach (KeyValuePair<Thread, string> kvp in ReadLockers)
// {
// System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name);
// System.Console.WriteLine("------------------------------------------");
// }
} }
catch catch
{} {}
@ -114,6 +125,16 @@ namespace OpenSim.Framework
if (m_itemLock.RecursiveWriteCount > 0) if (m_itemLock.RecursiveWriteCount > 0)
{ {
m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
// try
// {
// System.Console.WriteLine("------------------------------------------");
// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
// System.Console.WriteLine("------------------------------------------");
// System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
// System.Console.WriteLine("------------------------------------------");
// }
// catch
// {}
m_itemLock.ExitWriteLock(); m_itemLock.ExitWriteLock();
} }
@ -123,15 +144,16 @@ namespace OpenSim.Framework
if (m_itemLock.IsWriteLockHeld) if (m_itemLock.IsWriteLockHeld)
{ {
m_itemLock = new System.Threading.ReaderWriterLockSlim(); m_itemLock = new System.Threading.ReaderWriterLockSlim();
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
System.Console.WriteLine("Locker's call stack:\n" + WriterStack); // System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
LockedByThread = null; // LockedByThread = null;
ReadLockers.Clear(); // ReadLockers.Clear();
} }
} }
// ReadLockers[Thread.CurrentThread] = Environment.StackTrace;
} }
else else
{ {
@ -139,6 +161,8 @@ namespace OpenSim.Framework
{ {
m_itemLock.ExitReadLock(); m_itemLock.ExitReadLock();
} }
// if (m_itemLock.RecursiveReadCount == 0)
// ReadLockers.Remove(Thread.CurrentThread);
} }
} }
@ -158,6 +182,7 @@ namespace OpenSim.Framework
if (m_itemLock.RecursiveWriteCount > 0) if (m_itemLock.RecursiveWriteCount > 0)
{ {
m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
m_itemLock.ExitWriteLock(); m_itemLock.ExitWriteLock();
} }
while (!m_itemLock.TryEnterWriteLock(60000)) while (!m_itemLock.TryEnterWriteLock(60000))
@ -165,30 +190,30 @@ namespace OpenSim.Framework
if (m_itemLock.IsWriteLockHeld) if (m_itemLock.IsWriteLockHeld)
{ {
m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
System.Console.WriteLine("Locker's call stack:\n" + WriterStack); // System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
} }
else else
{ {
m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by a reader. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by a reader. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
System.Console.WriteLine("My call stack:\n" + Environment.StackTrace); // System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
foreach (KeyValuePair<Thread, string> kvp in ReadLockers) // foreach (KeyValuePair<Thread, string> kvp in ReadLockers)
{ // {
System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name); // System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name);
System.Console.WriteLine("------------------------------------------"); // System.Console.WriteLine("------------------------------------------");
} // }
} }
m_itemLock = new System.Threading.ReaderWriterLockSlim(); m_itemLock = new System.Threading.ReaderWriterLockSlim();
ReadLockers.Clear(); // ReadLockers.Clear();
} }
LockedByThread = Thread.CurrentThread; LockedByThread = Thread.CurrentThread;
WriterStack = Environment.StackTrace; // WriterStack = Environment.StackTrace;
} }
else else
{ {