[MGNLREST-148] Delivery endpoint fails when multiple concurrent requests Created: 09/Nov/17  Updated: 20/Nov/17  Resolved: 13/Nov/17

Status: Closed
Project: Magnolia REST Framework
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0

Type: Bug Priority: Critical
Reporter: Christopher Zimmermann Assignee: Dai Ha
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 5h
Original Estimate: Not Specified

Attachments: File problem-node.js     HTML File problem.html    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Sprint: Saigon 122
Story Points: 5

 Description   

If I issue multiple requests at the same time then I get sporadic failures (about half the time) where code 500 is returned, and exceptions are written to the log.
Sometimes the response contains message "writeStartObject() cannot be called in object context", sometimes it actually does return the proper response body - although it had the code 500.
The same problem happens if i hit three different "endpointPrefixes" at the same time, instead of the same "prefix" multiple times.

If I only issue one request at a time, there are no errors and I get the expected response.

I have the CORS filter installed on my server in order to make requests to it from another server in a headless fashion. (https://wiki.magnolia-cms.com/display/WIKI/CORS+filter+documentation)

Please see attachments to reproduce the error.
"problem.html" - simple webpage to open in browser.
"problem-node.js" run from command line with: node problem-node.js

My endpoint configuration is as follows.
The problem happens less if I remove the referenceresolvers, but still happens a few times.

  tours:
    nodeTypes:
      0: mgnl:content
    includeSystemProperties: false
    bypassWorkspaceAcls: true
    limit: 50
    references:
      tourTypes:
        propertyName: tourTypes
        referenceResolver:
          implementationClass: info.magnolia.rest.reference.jcr.UuidReferenceResolver
          targetWorkspace: category
      destinations:
        propertyName: destination
        referenceResolver:
          implementationClass: info.magnolia.rest.reference.jcr.UuidReferenceResolver
          targetWorkspace: category


 Comments   
Comment by Dai Ha [ 10/Nov/17 ]

NodeWriter holding a currentLevel integer to tracking json writing and there is only one NodeWriter instance shared between request. The problem report here probably is the result of requests reset/changed currentLevel value causing jsonGenerator failed to operate.

Solution:
+ synchronized write flow of NodeWriter -> tested and it might work but there is bottle neck to deal with later
+ try to bind currentLevel with its jsonGenerator.

Comment by Dai Ha [ 10/Nov/17 ]

The fix that binds currentLevel to jsonGenerator available here:
PR

Comment by Dai Ha [ 14/Nov/17 ]

verify with bundle: magnolia-enterprise-pro-demo-bundle-5.6-20171113.193805-211-tomcat-bundle.zip. Issue fixed.

Generated at Mon Feb 12 06:57:05 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.