[Mulgara-dev] Emailing: protocolServlet POST answer cleanup.patch

David Smith DMS at viewpointusa.com
Tue Jan 19 12:40:42 UTC 2010


We are still seeing lots of these "TransactionalAnswer not closed"
messages when converting from SOAP to REST(POST method).
Lots being 30-60 messages in the log at the same timestamp multiple
times per second

Any ideas?


Dave S

========================================================================
=================================================


Index: ProtocolServlet.java
===================================================================
--- ProtocolServlet.java	(revision 1888)
+++ ProtocolServlet.java	(working copy)
@@ -106,7 +106,7 @@
 
   /** The default output type to use. */
   protected static final Output DEFAULT_OUTPUT_TYPE = Output.XML;
-  
+
   /** The default output type to use for queries that return graph
results. */
   protected static final Output DEFAULT_GRAPH_OUTPUT_TYPE =
Output.RDFXML;
 
@@ -202,7 +202,7 @@
       }
 
       Answer result = executeQuery(query, req);
-      
+
       Output outputType = getOutputType(req, query);
       sendAnswer(result, outputType, resp);
 
@@ -476,19 +476,23 @@
    * @param req The query request object.
    * @param resp The HTTP response object.
    * @throws IOException If an error occurs when communicating with the
client.
-   * @throws ServletException 
+   * @throws ServletException
    */
   protected void handleUpdateQuery(HttpServletRequest req,
HttpServletResponse resp) throws IOException, ServletException {
+
     String queryStr = req.getParameter(QUERY_ARG);
+
     List<Command> cmds = getCommand(queryStr, req);
 
     boolean tx = cmds.size() > 1;
     if (tx) executeCommand(new SetAutoCommit(false), req);
+
     Object finalResult = null;
     Output finalOutputType = null;
 
     Object tmpResult = null;
     Output tmpOutputType = null;
+
     try {
       try {
         for (Command cmd: cmds) {
@@ -498,8 +502,16 @@
           }
           tmpResult = executeCommand(cmd, req);
           tmpOutputType = getOutputType(req, cmd);
+
           // remember the last answer we see
           if (tmpResult instanceof Answer) {
+			if( finalResult != null && finalResult
instanceof Answer ) {
+			  try {
+				((Answer)finalResult).close();	 //
we're about to replace this one, so close it.
+			  } catch (TuplesException e) {
+				throw new InternalErrorException("Error
closing: " + e.getMessage());
+			  }
+			}
             finalResult = tmpResult;
             finalOutputType = tmpOutputType;
           }
@@ -514,24 +526,34 @@
         finalResult = tmpResult;
         finalOutputType = tmpOutputType;
       }
-  
+
       if (finalResult instanceof Answer) {
         sendAnswer((Answer)finalResult, finalOutputType, resp);
       } else {
         sendStatus(finalResult, finalOutputType, resp);
       }
+
     } finally {
-      // always turn on autocommit since we can't leave a transaction
running in HTTP
-      try {
-        if (tx) executeCommand(new SetAutoCommit(true), req);
-      } catch (Exception e) {
-        // throw away
-        logger.error("Unable to close transaction", e);
+
+	  try {
+	    if( finalResult != null && finalResult instanceof Answer) {
+	  	  ((Answer)finalResult).close();
+	    }
+	  } catch (TuplesException e) {
+	    throw new InternalErrorException("Error closing finalResult:
" + e.getMessage());
+	  } finally {
+
+        // always turn on autocommit since we can't leave a transaction
running in HTTP
+        try {
+          if (tx) executeCommand(new SetAutoCommit(true), req);
+        } catch (Exception e) {
+          // throw away
+          logger.error("Unable to close transaction", e);
+        }
       }
     }
   }
 
-
   /**
    * Load MIME data into a graph.
    * @param graph The graph to load into.
@@ -811,7 +833,7 @@
     final String mimeText;
     final boolean isGraphType;
     final boolean isBindingType;
-    private Output(String mimeText, boolean isGraphType, boolean
isBindingType) { 
+    private Output(String mimeText, boolean isGraphType, boolean
isBindingType) {
       this.mimeText = mimeText;
       this.isGraphType = isGraphType;
       this.isBindingType = isBindingType;
@@ -821,7 +843,7 @@
     static {
       for (Output o: Output.values()) outputs.put(o.mimeText, o);
     }
-    
+
     static Output forMime(String mimeText) { return
outputs.get(mimeText); }
   }
 
@@ -854,7 +876,7 @@
 
       defaultGraphUris = getUriParamList(DEFAULT_GRAPH_ARG, params);
       namedGraphUris = getUriParamList(NAMED_GRAPH_ARG, params);
-      
+
       graph = getUriParam(GRAPH_DATA, params);
 
       // a single default-graph-uri is equivalent to a graph
@@ -954,7 +976,7 @@
       if (namedGraphUris != null && !namedGraphUris.isEmpty()) {
         throw new BadRequestException("Named graphs not valid with a
graph resource.");
       }
-      
+
       return ResourceType.GRAPH;
     }





-----Original Message-----
From: David Smith 
Sent: Monday, January 18, 2010 8:41 AM
To: Mulgara Developers
Subject: Emailing: protocolServlet POST answer cleanup.patch

After installing the patch for POST with subqueries, I was encountering
a large number of:

2010-01-16 16:14:44,256 [Finalizer] -
org.mulgara.resolver.TransactionalAnswer - TransactionalAnswer not
closed

I think this patch cleans up a hole in the POST servlet answer handling,
but I am still encountering a large number of the not closed errors.

Unfortunately I don't have the visibility I need to know what queries
are being run.
Is there anywhere else we need to look to handle these errors.

Dave Smith
Viewpoint

This E-Mail may contain confidential and privileged information. It is intended solely for the recipient(s) indicated. Any review, use, or distribution by anyone other than the intended recipient(s) is strictly prohibited. If you have received this E-Mail in error or are not the intended recipient, please notify the sender and delete all copies immediately.



More information about the Mulgara-dev mailing list