incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1163260 - in /incubator/lcf/trunk: CHANGES.txt framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java
Date Tue, 30 Aug 2011 15:25:32 GMT
Author: kwright
Date: Tue Aug 30 15:25:32 2011
New Revision: 1163260

URL: http://svn.apache.org/viewvc?rev=1163260&view=rev
Log:
Fix for CONNECTORS-244. Catch a deadlock condition that occurs on a query outside of a transaction
on Derby (!).

Modified:
    incubator/lcf/trunk/CHANGES.txt
    incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java

Modified: incubator/lcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/CHANGES.txt?rev=1163260&r1=1163259&r2=1163260&view=diff
==============================================================================
--- incubator/lcf/trunk/CHANGES.txt (original)
+++ incubator/lcf/trunk/CHANGES.txt Tue Aug 30 15:25:32 2011
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 0.3-dev =========================
 
+CONNECTORS-244: Add a fix to recover for another Derby deadlock situation.
+(Karl Wright)
+
 CONNECTORS-243: Include most response headers in the metadata for
 each web connector document.
 (Jan H√łydahl, Karl Wright)

Modified: incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java?rev=1163260&r1=1163259&r2=1163260&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java
(original)
+++ incubator/lcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java
Tue Aug 30 15:25:32 2011
@@ -381,22 +381,49 @@ public class IncrementalIngester extends
     if (documentURI != null)
       documentURIHash = ManifoldCF.hash(documentURI);
 
+    String oldURI = null;
+    String oldURIHash = null;
+    String oldOutputVersion = null;
+
     // See what uri was used before for this doc, if any
     ArrayList list = new ArrayList();
     list.add(docKey);
     list.add(connection.getName());
-    IResultSet set = performQuery("SELECT "+docURIField+","+uriHashField+","+lastOutputVersionField+"
FROM "+getTableName()+
-      " WHERE "+docKeyField+"=? AND "+outputConnNameField+"=?",list,null,null);
-
-    String oldURI = null;
-    String oldURIHash = null;
-    String oldOutputVersion = null;
-    if (set.getRowCount() > 0)
+    
+    while (true)
     {
-      IResultRow row = set.getRow(0);
-      oldURI = (String)row.getValue(docURIField);
-      oldURIHash = (String)row.getValue(uriHashField);
-      oldOutputVersion = (String)row.getValue(lastOutputVersionField);
+      long sleepAmt = 0L;
+      try
+      {
+        IResultSet set = performQuery("SELECT "+docURIField+","+uriHashField+","+lastOutputVersionField+"
FROM "+getTableName()+
+          " WHERE "+docKeyField+"=? AND "+outputConnNameField+"=?",list,null,null);
+
+        if (set.getRowCount() > 0)
+        {
+          IResultRow row = set.getRow(0);
+          oldURI = (String)row.getValue(docURIField);
+          oldURIHash = (String)row.getValue(uriHashField);
+          oldOutputVersion = (String)row.getValue(lastOutputVersionField);
+        }
+        
+        break;
+      }
+      catch (ManifoldCFException e)
+      {
+        // Look for deadlock and retry if so
+        if (e.getErrorCode() == e.DATABASE_TRANSACTION_ABORT)
+        {
+          if (Logging.perf.isDebugEnabled())
+            Logging.perf.debug("Aborted select looking for status: "+e.getMessage());
+          sleepAmt = getSleepAmt();
+          continue;
+        }
+        throw e;
+      }
+      finally
+      {
+        sleepFor(sleepAmt);
+      }
     }
 
     // If uri hashes collide, then we must be sure to eliminate only the *correct* records
from the table, or we will leave



Mime
View raw message