cancel
Showing results for 
Search instead for 
Did you mean: 

Transactions not getting commited on cluster

swatnew1
Champ on-the-rise
Champ on-the-rise
I have written java backed webscript which will call webservice and webservice response has metadata to be updated for node .

This webscript is  to update more than 1000 documents with some delay in each document processing .
But its observed that on cluser env . If I run it , it does not update all docs in one go .
It updates 30% to 50% docs . Hence I have to run it for multiple times.

what's wrong with this approach ?
8 REPLIES 8

mrogers
Star Contributor
Star Contributor
There will be some limit on the number of docs you can update at once, so at some point you will want to split your huge request into smaller batches.   However I'd expect 1000 docs to be O.K.    Perhaps that's too big for your use case so try splitting into batches of 100.

What do you mean by the following?
If I run it, it does not update all docs in one go .
Either all docs should succeed or fail.    Could you explain what you mean by 30% ?  

swatnew1
Champ on-the-rise
Champ on-the-rise
That's what is strange. Eg. if 1000 docs to be updated , and I run webscript , I find it will update 500 docs not all . So as still 500 to be updated , I will run it again and I find its updating 200 docs. That's how its working . Same code works perfectly when I tested for 100 docs on single node without any issue ,but problem with cluster env.

openpj
Elite Collaborator
Elite Collaborator
Could you please share with us your implementation of this Java Backed WebScript?

swatnew1
Champ on-the-rise
Champ on-the-rise
Sorry , its not java backed , but script based webservice

Few methods as below for java class :
   private void updateInteractionStatus(NodeRef node ,String msg , String interactionId)
   {
      log.debug("updateInteractionStatus : :" );
      if(!nodeService.hasAspect(node,  ExtContentModel.ASPECT_INTERACTION_INFO))
      {
         log.debug("updateInteractionStatus :   adding aspect  :" );
         Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>();
         aspectProps.put(ExtContentModel.PROP_INTERACTION_STATUS, msg);
         aspectProps.put(ExtContentModel.PROP_INTERACTIONID, interactionId);
         aspectProps.put(ExtContentModel.PROP_INTERACTION_TYPE, CREATE_INTERACTION_TYPE);

         nodeService.addAspect(node, ExtContentModel.ASPECT_INTERACTION_INFO, aspectProps);
      }
      else
      {
         log.debug("updateInteractionStatus : setting aspect   :" );
         //   serviceRegistry.getAuthenticationService().authenticate("admin","admin".toCharArray());

         Map<QName, Serializable> props = nodeService.getProperties(node);

         props.put(ExtContentModel.PROP_INTERACTION_STATUS, msg);
         props.put(ExtContentModel.PROP_INTERACTIONID, interactionId);
         props.put(ExtContentModel.PROP_INTERACTION_TYPE, CREATE_INTERACTION_TYPE);

         nodeService.setProperties(node, props);

      }
   }


   /**
    * Method to process CreateInteraction calls for Exbo documents
    */
   public void processFailedExboDocs()
   {
      try
      {
         System.out.println("DocumentUploadScriptAction  processFailedExboDocs>>");
         ResultSet docResultSet =serviceRegistry.getSearchService().
               query(storeRef,
                     SearchService.LANGUAGE_LUCENE,
                     "PATH:\"/app:company_home/st:sites/cm:customersupport/cm:documentLibrary/cm:BASE/cm:INVALID/cm:EXBO//*\" OR PATH:\"/app:company_home/st:sites/cm:customersupport/cm:documentLibrary/cm:BASE/cm:INCOMING/cm:EXBO//*\" OR PATH:\"/app:company_home/st:sites/cm:customersupport/cm:documentLibrary/cm:BASE/cm:TO_BE_ARCHIVED/cm:EXBO//*\""
                     );

         List<NodeRef> nodeRefs = docResultSet.getNodeRefs();
         createInteractionRetrail(nodeRefs );
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
   }


——————————————————————————–
CreateInteractionWS.get.js
validationProcessor.processFailedExboDocs(); // validationProcessor is subclass of BaseScopableProcessorExtension
——————————————————————————–
CreateInteractionWS.get.desc.xml

<webscript>
  <shortname>Archieve</shortname>
  <description>Document List Action - Backup document(s)</description>
  <url>/CreateNewInteraction</url>
  <format default="html">argument</format>
  <authentication>user</authentication>
</webscript>
——————————————————————————-
CreateInteractionWS.get.html.ftl
<html>
  <body>
     DataCorrection >> Update metadata / movement done successfully.
      <p>Hello ${person.properties.userName}</p>
  </body>
</html>

swatnew1
Champ on-the-rise
Champ on-the-rise
I can not put all code here , Its script based webscript where I am calling custom BaseScopableProcessorExtension object's method from javascript .
This method then does processing ,

Below method where I set properties , does not work as per expectation.

private void updateInteractionStatus(NodeRef node ,String msg , String interactionId)
{
log.debug("updateInteractionStatus : :" );
if(!nodeService.hasAspect(node, ExtContentModel.ASPECT_INTERACTION_INFO))
{
log.debug("updateInteractionStatus : adding aspect :" );
Map aspectProps = new HashMap();
aspectProps.put(ExtContentModel.PROP_INTERACTION_STATUS, msg);
aspectProps.put(ExtContentModel.PROP_INTERACTIONID, interactionId);
aspectProps.put(ExtContentModel.PROP_INTERACTION_TYPE, CREATE_INTERACTION_TYPE);

nodeService.addAspect(node, ExtContentModel.ASPECT_INTERACTION_INFO, aspectProps);
}
else
{
log.debug("updateInteractionStatus : setting aspect :" );
// serviceRegistry.getAuthenticationService().authenticate("admin","admin".toCharArray());

Map props = nodeService.getProperties(node);

props.put(ExtContentModel.PROP_INTERACTION_STATUS, msg);
props.put(ExtContentModel.PROP_INTERACTIONID, interactionId);
props.put(ExtContentModel.PROP_INTERACTION_TYPE, CREATE_INTERACTION_TYPE);

nodeService.setProperties(node, props);

}
}

swatnew1
Champ on-the-rise
Champ on-the-rise
I hope you are getting my implementation .

mrogers
Star Contributor
Star Contributor
That exception processing is not correct.

You are swallowing exceptions that should result in a retry.   Your java script should execute as one transaction.    If you want control of your transactions (and you may also need the batching stuff) then rewrite in Java.

swatnew1
Champ on-the-rise
Champ on-the-rise
I  added User Transaction code , but still same problem was there .
Also I added try catch , it was not throwing any exception.