View Revisions: Issue #863

Summary 0000863: Prevent race condition for read/write of savapage.json
Revision 2017-09-08 19:34 by rijkr
Description IST: Sometimes, a "com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in field name" is encountered when reading a user's savapage.json file. This indicates that the file is incomplete, which could be due to a read/write "race condition". For example, after a PDF upload, the UserEventService gets a notification from the Linux file system of the newly created PDF, and immediately reads the PDF meta data from the savapage.json file, while at the same time the same json file is being written by another thread.

SOLL: Create savapage.json as temp file and do atomic move to target location.

NOTE: This issue was observed on VMware with an extra mounted disk (XFS File System) dedicated for temporary files and user inboxes. On the same system it was also observed that an atomic file move sometimes fails, due to the fact that the source file is reported missing, although a Java File.exists(), just before the move, reports that the file is present.
Revision 2017-09-08 20:11 by rijkr
Description IST: Sometimes, a "com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in field name" is encountered when reading a user's savapage.json file. This indicates that the file is incomplete, which could be due to a read/write "race condition". For example, after a PDF upload, the UserEventService gets a notification from the Linux file system of the newly created PDF, and immediately reads the PDF meta data from the savapage.json file, while at the same time the same json file is being written by another thread.

SOLL: Create savapage.json as temp file and do atomic move to target location.

NOTE: This issue was observed on VMware with an extra mounted disk (XFS File System) dedicated for temporary files and user inboxes.
Revision 2017-09-08 20:34 by rijkr
Description IST: Sometimes, a "com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in field name" is encountered when reading a user's savapage.json file. This indicates that the file is incomplete, which could be due to a read/write "race condition". For example, after a PDF upload, the UserEventService gets a notification from the Linux file system of the newly created PDF, and immediately reads the PDF meta data from the savapage.json file, while at the same time the same json file is being written by another thread.
SOLL: Create savapage.json as temp file and do atomic move to target location.
NOTE: This issue was observed on VMware with an extra mounted disk (XFS File System) dedicated for temporary files and user inboxes.
Revision 2017-09-08 19:34 by rijkr
Additional Information 2017-09-07 14:56:23,468 ERROR UserEventService:559 - Error parsing from file [/opt/spool/savapage/safepages/0/1/some-userid/savapage.json] [jetty-threadpool-4604]
org.savapage.core.SpException: Error parsing from file [/opt/spool/savapage/safepages/0/1/some-userid/savapage.json]
        at org.savapage.core.services.impl.InboxServiceImpl.readInboxInfo(InboxServiceImpl.java:191)
        at org.savapage.core.services.impl.InboxServiceImpl.getInboxInfo(InboxServiceImpl.java:244)
        at org.savapage.core.services.helpers.InboxPageImageChunker.<init>(InboxPageImageChunker.java:212)
        at org.savapage.core.services.helpers.InboxPageImageChunker.chunk(InboxPageImageChunker.java:663)
        at org.savapage.core.services.impl.InboxServiceImpl.getPageChunks(InboxServiceImpl.java:754)
        at org.savapage.server.cometd.UserEventService.getChangedJobsEvent(UserEventService.java:1031)
        at org.savapage.server.cometd.UserEventService.watchUserFileEvents(UserEventService.java:897)
        at org.savapage.server.cometd.UserEventService.monitorUserEvent(UserEventService.java:518)
...
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in field name
 at [Source: /opt/spool/savapage/safepages/0/1/some-userid/savapage.json; line: 168, column: 4010]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1378)
....
 at org.savapage.core.services.impl.InboxServiceImpl.readInboxInfo(InboxServiceImpl.java:171)
        ... 32 more
2017-09-07 14:56:23,473 ERROR AppLogServiceImpl:121 - UserEventService: SpException: Error parsing from file [/opt/spool/savapage/safepages/0/1/some-userid/savapage.json] (User "some-userid" at WebApp 127.0.0.1) [jetty-threadpool-4604]
Revision 2017-09-08 20:34 by rijkr
Additional Information 2017-09-07 14:56:23,468 ERROR UserEventService:559 - Error parsing from file [/opt/spool/savapage/safepages/0/1/some-userid/savapage.json] [jetty-threadpool-4604]
org.savapage.core.SpException: Error parsing from file [/opt/spool/savapage/safepages/0/1/some-userid/savapage.json]
        at org.savapage.core.services.impl.InboxServiceImpl.readInboxInfo(InboxServiceImpl.java:191)
        at org.savapage.core.services.impl.InboxServiceImpl.getInboxInfo(InboxServiceImpl.java:244)
        at org.savapage.core.services.helpers.InboxPageImageChunker.<init>(InboxPageImageChunker.java:212)
        at org.savapage.core.services.helpers.InboxPageImageChunker.chunk(InboxPageImageChunker.java:663)
        at org.savapage.core.services.impl.InboxServiceImpl.getPageChunks(InboxServiceImpl.java:754)
        at org.savapage.server.cometd.UserEventService.getChangedJobsEvent(UserEventService.java:1031)
        at org.savapage.server.cometd.UserEventService.watchUserFileEvents(UserEventService.java:897)
        at org.savapage.server.cometd.UserEventService.monitorUserEvent(UserEventService.java:518)
. . .
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in field name
 at [Source: /opt/spool/savapage/safepages/0/1/some-userid/savapage.json; line: 168, column: 4010]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1378)
. . .
 at org.savapage.core.services.impl.InboxServiceImpl.readInboxInfo(InboxServiceImpl.java:171)
        ... 32 more
2017-09-07 14:56:23,473 ERROR AppLogServiceImpl:121 - UserEventService: SpException: Error parsing from file [/opt/spool/savapage/safepages/0/1/some-userid/savapage.json] (User "some-userid" at WebApp 127.0.0.1) [jetty-threadpool-4604]