2

We have been experiencing Domino server crashes lately. We have found that the crashes are caused by parallel calls to the same Xpage by the same user.

We have now chained the Ajax calls to the Xpage so that they are synchronous and the crashes have stopped.

As we would like to move towards more Ajax calls towards Xpages (Xagent style) in future development we would like to know why this is occurring and how to solve it. We can't find any code in the javacode that needs to be synchronized.

Is this known issue. How can we get around this issue whithout performing all calls synchronously?

Summary of solution that causes error:

A web page calls an Xpage that calls XAgent via SSJS in afterRenderResponse. Javaclass reads Post Request and send JSON back via FacesContext.

Detailed description:

We call the Xpage via Ajax POST calls. Sometimes these calls are performed toward the same Xpage by the same user in parallell. (That is when we get crashes)

IE in javascript (Angular):

Code that crashes server:

$http.post('xpage1.xsp',data1,config).then(){
     Do stuff with response from call1
 }
 $$http.post('xpage1.xsp',data2,config).then(){
         Do stuff with response from call2
 }

Code that works:

$http.post('xpage1.xsp',data1,config).then(){
       Do stuff with response from call1;
         $$http.post('xpage1.xsp',data2,config).then(){
             Do stuff with response from call2
        }
 }

where the data is just is an object containg requestdata and config is just config for the HTTP call.

The Xpage is calling the javacode in the AfterRenderResponse event of the Xpage. ((XAgent framework)

The Javacode is Using The FacesContext Object to read the request and to create a response. It Reads the JSON posted and gets a document. which it creates a Java object of .We then create new JSON from the JavaObject via GSON and send this JSON as response to browser.

        private static FacesContext faccon;
        private static ExternalContext extcon;
        private static HttpServletRequest request;
        private static HttpServletResponse response;
        private String logOn ="";
        private boolean javaDebuggingOn = false;

       public SaveCtrl() {
          faccon = FacesContext.getCurrentInstance();
          extcon = faccon.getExternalContext();
          request = (HttpServletRequest) extcon.getRequest();
          response = (HttpServletResponse) extcon.getResponse();
       }

     public void post() throws IOException {
          String processName = className + "." + "post";

          response.setHeader("Cache-Control", "no-cache");
          response.setContentType("application/json");
          response.setCharacterEncoding("UTF-8");
          response.setStatus(200); // HTTP OK

          ResponseWriter writer = faccon.getResponseWriter();
          //Handle JSON in POST  Request
          String requestBody = extractPostRequestBody(request);
          String action = requestData.get("action");


        //Send JSON response
        Gson gson = new GsonBuilder()
        .setDateFormat("yyyy-MM-dd HH:mm:ss")
        .create();

        List myList = getList(action);
        String jsonOut= gson.toJson(myList );


        writer.write(jsonOut);


         writer.endDocument();
         faccon.responseComplete();

     }
jalmen
  • 191
  • 1
  • 9
  • Does Domino crash completely so that you have to restart it? – Per Henrik Lausten Apr 09 '19 at 08:08
  • HTTP task crashes and restarts – jalmen Apr 09 '19 at 08:17
  • Does log.nsf or logs in data/IBM_TECHNICAL_SUPPORT mention anything relevant about the crash (such as memory issues)? – Per Henrik Lausten Apr 09 '19 at 08:18
  • No we are montoring memory and jvm memory and no memory problems and no details in crash dumps which we have sent to IBM. the only clue is that it point to the xpage we are calling as the problem – jalmen Apr 09 '19 at 08:20
  • What version of Domino? – Per Henrik Lausten Apr 09 '19 at 08:21
  • 9.01 FP7 and also 9.01 FP10 – jalmen Apr 09 '19 at 08:24
  • How do you ensure that the objects in FacesContext are stored thread safe? For me, the complete error description sounds like concurrency problems (in your code)... – Sven Hasselbach Apr 09 '19 at 09:06
  • Added code in Question as to how I am referencing the facescontext. Maybe not the correct way. Which code should be synchronized here? – jalmen Apr 09 '19 at 09:40
  • Sorry, I thought you are storing something in FacesContext ("...and send JSON back via FacesContext..."). – Sven Hasselbach Apr 09 '19 at 14:56
  • But calling an XAgent from an XPage from a Website, and when doing this in parallel for a single user it results in server crashes: Its a concurrency problem. There are some Anti-DOS protections in XPages which "block" requests from the same user. – Sven Hasselbach Apr 09 '19 at 15:08
  • Added just the part of gettting and writing Json in the code. – jalmen Apr 10 '19 at 08:42
  • So there is a built in protection agains running the same Xpage for the same user concurrently? Then this protection seems not to be working as it is when run at the same time that it crashes. – jalmen Apr 10 '19 at 08:44
  • No, there is a protection for not starting too many HTTP threads for the same user. The requests will then be blocked, until a thread is finished. In your architecture, you are creating a request in the request itself. What if the request is blocked because of too many requests? Timeout? How do you access the XAgent from your XPage? There are a lot of open questions here. What have you tried to isolate the problem? – Sven Hasselbach Apr 10 '19 at 10:12
  • We are not calling a request within a request. They are called asynchronously so the other call is not called whithin the other call. The JS above is not full code only a summary of the logic. I can paste in the whole JS Code so you can see. We have one Xpage that runs js . code on a button, This button onclick code creates 2 separate asynchronous calls to an Xpage Url. This Xpage calls Java Code in AfterRenderResponse . IE it is just used as a REST service. The response is returned as JSON. – jalmen Apr 11 '19 at 10:01
  • 1
    "A web page calls an Xpage that calls XAgent via SSJS in afterRenderResponse". I am off. – Sven Hasselbach Apr 11 '19 at 10:04
  • That is a regular "XAgent" call. IE Calling an Xpage with SSJS in afterrenderresponse. The SSJS code is a call to java class with a run method that returns JSON. Not sure if that is classed as a request whitin a request ? – jalmen Apr 11 '19 at 10:49

2 Answers2

1

Are you setting viewState="nostate" on your XPage? If not, you're serialising and deserialising component trees for the page and they're shared. That could cause problems and I can understand why it might cause crashes. If you're using it only for REST access there is no reason to store component trees, so set it in application's XSP Properties. It's not enabled by default because typical XPages applications should keep page history. But you're not using it as a typical XPages application, instead as a simple REST service application.

Paul Stephen Withers
  • 15,699
  • 1
  • 15
  • 33
1

The answer was that there is som error in the code reading and writing the response when this was changed to a REST component the calls are functioning in parallel.

jalmen
  • 191
  • 1
  • 9