[QFJ-969] Thread Safety FileStore.set Created: 28/Jan/19 Updated: 28/Jan/19 |
|
Status: | Open |
Project: | QuickFIX/J |
Component/s: | Engine |
Affects Version/s: | 2.1.0 |
Fix Version/s: | None |
Type: | Improvement | Priority: | Minor |
Reporter: | Yanick Salzmann | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 0 |
Labels: | Message, QuickfixJ |
Description |
When seeking for optimizations for file sync I have come across the FileStore.set method and was wondering about its thread safety. I labelled this issue as improvement, because I am not sure if it is maybe already been taken care of somewhere else, however lets look at this method: As you can see, at the very beginning of the function the offset inside the RandomAccessFile is taken as the message offset. The actual writing of the information happens after many more instructions, one of them even including a synchronization on a file descriptor. According to my understanding the offset obtained on line 365 could easily be outdated by the time the message is written at line 377. Of course it is possible, that synchronization is supposed to be happening outside of the set method, however I do not see any contract enforcing this in MessageStore.set. Should this method not be thread safe to avoid potential data inconsitencies? |
Comments |
Comment by Christoph John [ 28/Jan/19 ] |
Hi Yanick Salzmann, as far as I am aware the MessageStore.set() method is only accessed from Session.sendRaw() where it is guarded by a lock. But yeah, in theory it could happen that it is accessed concurrently. It seems like this could happen especially on shutdown. See QFJ-762. Cheers, |