[mapguide-commits] r5518 - branches/2.2/MgDev/Server/src/Common/Manager

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Feb 4 16:38:17 EST 2011


Author: trevorwekel
Date: 2011-02-04 13:38:17 -0800 (Fri, 04 Feb 2011)
New Revision: 5518

Modified:
   branches/2.2/MgDev/Server/src/Common/Manager/CacheManager.cpp
   branches/2.2/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
   branches/2.2/MgDev/Server/src/Common/Manager/FdoConnectionManager.h
Log:
Ticket #1584 Feature source create or update locks up server while under load
Submit patch to 2.2 branch

Modified: branches/2.2/MgDev/Server/src/Common/Manager/CacheManager.cpp
===================================================================
--- branches/2.2/MgDev/Server/src/Common/Manager/CacheManager.cpp	2011-02-01 02:03:57 UTC (rev 5517)
+++ branches/2.2/MgDev/Server/src/Common/Manager/CacheManager.cpp	2011-02-04 21:38:17 UTC (rev 5518)
@@ -118,10 +118,13 @@
 {
     // The mutex usage and the method call order here are important
     // because they ensure all the caches are in sync.
-    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_featureServiceCache.m_mutex));
+    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_fdoConnectionManager->sm_mutex));
+    {
+        ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_featureServiceCache.m_mutex));
 
-    m_fdoConnectionManager->ClearCache();
-    m_featureServiceCache.Clear();
+        m_fdoConnectionManager->ClearCache();
+        m_featureServiceCache.Clear();
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -157,10 +160,13 @@
     {
         // The mutex usage and the method call order here are important
         // because they ensure all the caches are in sync.
-        ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_featureServiceCache.m_mutex));
+        ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_fdoConnectionManager->sm_mutex));
+        {
+            ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_featureServiceCache.m_mutex));
 
-        m_fdoConnectionManager->RemoveCachedFdoConnection(resource);
-        m_featureServiceCache.RemoveEntry(resource);
+            m_fdoConnectionManager->RemoveCachedFdoConnection(resource);
+            m_featureServiceCache.RemoveEntry(resource);
+        }
     }
 }
 
@@ -174,10 +180,13 @@
     {
         // The mutex usage and the method call order here are important
         // because they ensure all the caches are in sync.
-        ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_featureServiceCache.m_mutex));
+       ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_fdoConnectionManager->sm_mutex));
+        {
+            ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_featureServiceCache.m_mutex));
 
-        m_fdoConnectionManager->RemoveCachedFdoConnection(resource);
-        m_featureServiceCache.RemoveEntry(resource);
+            m_fdoConnectionManager->RemoveCachedFdoConnection(resource);
+            m_featureServiceCache.RemoveEntry(resource);
+        }
     }
 }
 

Modified: branches/2.2/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
===================================================================
--- branches/2.2/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2011-02-01 02:03:57 UTC (rev 5517)
+++ branches/2.2/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2011-02-04 21:38:17 UTC (rev 5518)
@@ -21,6 +21,7 @@
 #include "LogManager.h"
 #include "LongTransactionManager.h"
 #include "CacheManager.h"
+#include "LogDetail.h"
 
 ACE_Recursive_Thread_Mutex ProviderInfo::sm_mutex;
 ACE_Recursive_Thread_Mutex MgFdoConnectionManager::sm_mutex;
@@ -224,6 +225,10 @@
 
     MG_FDOCONNECTION_MANAGER_TRY()
 
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.Open", mgStackParams);
+    logDetail.AddResourceIdentifier(L"Resource", resourceIdentifier);
+    logDetail.Create();
+
     ACE_TRACE ("MgFdoConnectionManager::Open");
 
     MgCacheManager* cacheManager = MgCacheManager::GetInstance();
@@ -322,14 +327,19 @@
 }
 
 FdoIConnection* MgFdoConnectionManager::Open(CREFSTRING provider, CREFSTRING connectionString)
-{
-    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, NULL));
-
+{    
     FdoPtr<FdoIConnection> pFdoConnection;
     ProviderInfo* providerInfo = NULL;
 
     MG_FDOCONNECTION_MANAGER_TRY()
 
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.Open", mgStackParams);
+    logDetail.AddString(L"Provider", provider);
+    logDetail.AddString(L"Connection", connectionString);
+    logDetail.Create();
+
+    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, NULL));
+
     ACE_TRACE ("MgFdoConnectionManager::Open");
 
     // The connection string may contain substitution tags that need updating
@@ -438,12 +448,17 @@
 
 void MgFdoConnectionManager::Close(FdoIConnection* pFdoConnection)
 {
-    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
-
     CHECKNULL((FdoIConnection*)pFdoConnection, L"MgFdoConnectionManager.Close()");
 
     MG_FDOCONNECTION_MANAGER_TRY()
 
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.Close", mgStackParams);
+    logDetail.AddInt64(L"FdoConnection", (INT64) pFdoConnection);
+    logDetail.Create();
+
+    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
+
+
     ACE_TRACE ("MgFdoConnectionManager::Close");
 
     // Make this connection available
@@ -453,11 +468,14 @@
 }
 
 void MgFdoConnectionManager::RemoveExpiredFdoConnections()
-{
+{  
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.RemoveExpiredFdoConnections", mgStackParams);
+    logDetail.Create();
+
     ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
 
-    MG_FDOCONNECTION_MANAGER_TRY()
-
     ACE_Time_Value now = ACE_OS::gettimeofday();
 
     // Loop all of the providers to get the FDO connection caches
@@ -622,12 +640,18 @@
 
 FdoIConnection* MgFdoConnectionManager::SearchFdoConnectionCache(CREFSTRING provider, CREFSTRING key, CREFSTRING ltName)
 {
-    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, NULL));
-
     FdoPtr<FdoIConnection> pFdoConnection;
 
     MG_FDOCONNECTION_MANAGER_TRY()
 
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.SearchFdoConnectionCache", mgStackParams);
+    logDetail.AddString(L"Provider", provider);
+    logDetail.AddString(L"Key", key);
+    logDetail.AddString(L"LTName", ltName);
+    logDetail.Create();
+
+    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, NULL));
+
     // Loop all of the providers to get the FDO connection caches
     ProviderInfoCollection::iterator iterProviderInfoCollection = m_ProviderInfoCollection.find(provider);
     if(m_ProviderInfoCollection.end() != iterProviderInfoCollection)
@@ -918,6 +942,12 @@
 
 void MgFdoConnectionManager::Open(FdoIConnection* pFdoConnection)
 {
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.Open", mgStackParams);
+    logDetail.AddInt64(L"FdoConnection",(INT64) pFdoConnection);
+    logDetail.Create();
+
     try
     {
         // Open the connection to the FDO provider
@@ -952,6 +982,8 @@
         throw new MgConnectionFailedException(L"MgFdoConnectionManager.Open",
             __LINE__, __WFILE__, NULL, L"", NULL);
     }
+
+    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(L"MgFdoConnectionManager.CacheFdoConnection")
 }
 
 STRING MgFdoConnectionManager::UpdateProviderName(CREFSTRING provider)
@@ -980,14 +1012,20 @@
 
 bool MgFdoConnectionManager::RemoveCachedFdoConnection(CREFSTRING resource, bool strict)
 {
+    bool success = false;
+
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.RemoveCachedFdoConnection", mgStackParams);
+    logDetail.AddString(L"Resource",resource);
+    logDetail.AddBool(L"Strict", strict);
+    logDetail.Create();
+
     ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, false));
 
-    bool success = false;
     INT32 connections = 0;
     INT32 connectionsRemoved = 0;
 
-    MG_FDOCONNECTION_MANAGER_TRY()
-
     if (resource.empty())
     {
         MgStringCollection arguments;
@@ -1130,6 +1168,12 @@
 {
     MG_FDOCONNECTION_MANAGER_TRY()
 
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.CacheFdoConnection", mgStackParams);
+    logDetail.AddString(L"Provider", provider);
+    logDetail.AddString(L"Key", key);
+    logDetail.AddString(L"LTName", ltName);
+    logDetail.Create();
+
     // Protect the cache
     ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
 
@@ -1194,6 +1238,10 @@
 
     MG_FDOCONNECTION_MANAGER_TRY()
 
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.UpdateFdoConnectionCache", mgStackParams);
+    logDetail.AddString(L"Provider", provider);
+    logDetail.Create();
+
     // Protect the cache
     ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, false));
 
@@ -1288,6 +1336,10 @@
 
     MG_FDOCONNECTION_MANAGER_TRY()
 
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.AcquireFdoConnection", mgStackParams);
+    logDetail.AddString(L"Provider", provider);
+    logDetail.Create();
+
     // Protect the cache
     ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, NULL));
 
@@ -1322,6 +1374,11 @@
 
 void MgFdoConnectionManager::ClearCache()
 {
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.ClearCache", mgStackParams);
+    logDetail.Create();
+
     ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
 
 #ifdef _DEBUG_FDOCONNECTION_MANAGER
@@ -1433,15 +1490,19 @@
     ACE_DEBUG ((LM_DEBUG, ACE_TEXT("MgFdoConnectionManager::ClearCache - FDO cache AFTER\n")));
     ShowCache();
 #endif
+    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(L"MgFdoConnectionManager.ClearCache")
 }
 
 
 void MgFdoConnectionManager::ShowCache()
 {
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.ShowCache", mgStackParams);
+    logDetail.Create();
+
     ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
 
-    MG_FDOCONNECTION_MANAGER_TRY()
-
     size_t cacheCollectionSize = m_ProviderInfoCollection.size();
     ACE_DEBUG ((LM_DEBUG, ACE_TEXT("MgFdoConnectionManager::ShowCache()\n")));
     ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Provider Information caches: %d\n"), cacheCollectionSize));
@@ -1499,10 +1560,16 @@
 
 ProviderInfo* MgFdoConnectionManager::GetProviderInformation(CREFSTRING provider)
 {
+    ProviderInfo* providerInfo = NULL;
+
+    MG_FDOCONNECTION_MANAGER_TRY()
+    
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.GetProviderInformation", mgStackParams);
+    logDetail.AddString(L"Provider", provider);
+    logDetail.Create();
+
     ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, NULL));
 
-    ProviderInfo* providerInfo = NULL;
-
     ProviderInfoCollection::iterator iter = m_ProviderInfoCollection.find(provider);
     if(iter != m_ProviderInfoCollection.end())
     {
@@ -1519,15 +1586,21 @@
         }
     }
 
+    
+    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(L"MgFdoConnectionManager.GetProviderInformation")
+
     return providerInfo;
 }
 
 void MgFdoConnectionManager::ShowProviderInfoCache()
 {
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.ShowProviderInfoCache", mgStackParams);
+    logDetail.Create();
+
     ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
 
-    MG_FDOCONNECTION_MANAGER_TRY()
-
     size_t cacheCollectionSize = m_ProviderInfoCollection.size();
     ACE_DEBUG ((LM_INFO, ACE_TEXT("MgFdoConnectionManager::ShowProviderInfoCache()\n")));
     ACE_DEBUG ((LM_INFO, ACE_TEXT("Provider Information cache size: %d\n"), cacheCollectionSize));
@@ -1582,10 +1655,14 @@
 
 void MgFdoConnectionManager::MakeFdoConnectionAvailable(FdoIConnection* connection)
 {
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.MakeFdoConnectionAvailable", mgStackParams);
+    logDetail.AddInt64(L"FdoConnection", (INT64) connection);
+    logDetail.Create();
+
     ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex));
 
-    MG_FDOCONNECTION_MANAGER_TRY()
-
 #ifdef _DEBUG_FDOCONNECTION_MANAGER
     ACE_DEBUG((LM_INFO, ACE_TEXT("MgFdoConnectionManager::MakeFdoConnectionAvailable - Provider Info Cache Before\n")));
     ShowProviderInfoCache();
@@ -1705,6 +1782,12 @@
     ProviderInfo* providerInfo = NULL;
     bool bConnectionAvailable = false;
 
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.TryAcquireFdoConnection", mgStackParams);
+    logDetail.AddString(L"Provider", provider);
+    logDetail.Create();
+
     // The code segment below needs to be guarded
     {
         ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, NULL));
@@ -1780,6 +1863,8 @@
         providerInfo = NULL;
     }
 
+    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(L"MgFdoConnectionManager.TryAcquireFdoConnection")
+
     return providerInfo;
 }
 
@@ -1788,6 +1873,11 @@
     STRING info = L"";
     wchar_t buffer[255];
 
+    MG_FDOCONNECTION_MANAGER_TRY()
+
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.GetFdoCacheInfo", mgStackParams);
+    logDetail.Create();
+
     ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, L""));
 
     // Add the header
@@ -1851,8 +1941,6 @@
 
     info += L"</ConfigurationSettings>";
 
-    MG_FDOCONNECTION_MANAGER_TRY()
-
     // Show the contents of the provider info cache collection
     INT32 nIndex = 1;
     for (ProviderInfoCollection::iterator iterCol = m_ProviderInfoCollection.begin();iterCol != m_ProviderInfoCollection.end(); iterCol++)
@@ -1993,10 +2081,10 @@
         info += L"</Provider>\n";
     }
 
+    info += L"</FdoCacheInformation>\n";
+
     MG_FDOCONNECTION_MANAGER_CATCH(L"MgFdoConnectionManager.GetFdoCacheInfo")
 
-    info += L"</FdoCacheInformation>\n";
-
     return info;
 }
 
@@ -2059,12 +2147,16 @@
 
 bool MgFdoConnectionManager::SetCachedFdoConnectionAsInvalid(MgResourceIdentifier* resource)
 {
-    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, false));
-
     bool success = false;
 
     MG_FDOCONNECTION_MANAGER_TRY()
 
+    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionManager.SetCachedFdoConnectionAsInvalid", mgStackParams);
+    logDetail.AddResourceIdentifier(L"Resource", resource);
+    logDetail.Create();
+
+    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, sm_mutex, false));
+
     STRING resId;
 
     if (NULL != resource)

Modified: branches/2.2/MgDev/Server/src/Common/Manager/FdoConnectionManager.h
===================================================================
--- branches/2.2/MgDev/Server/src/Common/Manager/FdoConnectionManager.h	2011-02-01 02:03:57 UTC (rev 5517)
+++ branches/2.2/MgDev/Server/src/Common/Manager/FdoConnectionManager.h	2011-02-04 21:38:17 UTC (rev 5518)
@@ -200,6 +200,8 @@
 
 class MG_SERVER_MANAGER_API MgFdoConnectionManager : public MgGuardDisposable
 {
+    friend class MgCacheManager;
+
     DECLARE_CLASSNAME(MgFdoConnectionManager)
 
 public:



More information about the mapguide-commits mailing list