Windows DFS delayed write

I know very little about DFS filesystems but have come across an issue with one of our deployments.

Our application writes files to a designated location, closes them, and then writes a record into the database. Another part of the application picks up these DB records and reads the file that was previous written.

In some cases the reader is getting a "file not found" and it fails. Restarting it without touching anything else and it finds the file correctly and everything is fine.

I believe I have ruled out a problem with our application as the file is definitely flushed/closed before the database record is created.

Therefore I'm led to believe that the OS or filesystem is delaying the file write internally so it isn't immediately available.

The filesystem in question is Windows 2003 SP2 DFS. Is this a likely scenario with this DFS? If so is it possible to switch it into some sort of write-through/no caching policy to ensure the files are written promptly?


Solution 1:

DFS is Distributed File System, which is exactly what the name says: a "virtual" file share that is distributed and replicated across multiple servers. Everytime your application writes to it, it's actually accessing one of its copies on one of the servers that are part of it, and if another application tries to read the same data soon after, it could very well be accessing another server, which didn't receive the updated data yet.

With DFS, you can't never be absolutely sure that data written to it will be available on a subsequent read: there could always be replication latency; you also don't have any way to tell your application to "talk" to a specific DFS server: it is free to connect to any one of the servers running it.

If you want this application to work in real time, you should use a standard file share, not a DFS.