gianm commented on issue #6665: Race between file reader and writer in 
FileSessionCredentialsProvider
URL: 
https://github.com/apache/incubator-druid/issues/6665#issuecomment-442364514
 
 
   Are you talking about Druid possibly reading partially-written content from 
a file? If so, then in general, the right way to update a file on a POSIX 
system that might have concurrent readers is to write a tmp file on the same 
filesystem, and then rename the new file over the old one. If you need the 
file's data to be durable after a system crash, you should fsync the file too, 
and the directory entry for the parent directory. The file updater external to 
Druid should be doing all of that, and if it does, then Druid can get a 
consistent read of the file.
   
   Mandatory locking is supported in Linux but frowned upon 
(https://lwn.net/Articles/667210/).
   
   See FileUtils.writeAtomically for an example of code in Druid that gets it 
(mostly) right. Although it's not fsyncing the containing directory entry, and 
it should be. That should be fixed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to