I'm using Transactional NTFS to atomize multiple writes to several files. The problem is that after commit, I may not be able to reopen a file, perhaps because of a racing condition.
The sequence of events is :
CreateTransaction
CreateFileTransacted
CloseHandle
CommitTransaction
CreateFile
for read/writeThe last step sometimes fails with error code 3 : ERROR_PATH_NOT_FOUND - The system cannot find the path specified. When re-executing the program, the file is then found. This happens rarely, but in a completely random manner, meaning not always when reopening the same file.
My theory is that if terminating the transaction by Windows takes a long time, the files are not available for opening in read/write mode until the transaction terminates. My program then fails when trying to open my own files in non-transaction mode.
I think that to avoid this problem, I need to wait for the transaction to complete before reopening the files. However, I have not found any documented method for doing that.
No clever answers, so I had to implement my own dummy one :
If an I/O error happens on opening a file that was just closed, the solution was to loop on opening several times while in-between calling Sleep() to release the CPU, before deciding that a catastrophic error had occurred.
Dummy solution, but it solved the problem.