延迟写入错误 [英] Delayed Write errors

查看:185
本文介绍了延迟写入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几个月里,我们一直在丢失数据的延迟写入错误。我所经历的误差与两个定制code和收缩包装的应用程序。例如,该错误信息下面从Visual Studio 2008来构建一个解决方案

For the past few months, we've been losing data to a Delayed Write errors. I've experienced the error with both custom code and shrink-wrap applications. For example, the error message below came from Visual Studio 2008 on building a solution

窗口 - 延迟写入失败:Windows无法
  保存所有数据的文件
  \\命门\\来源\\其它\\ OCHSHP \\ Done07 \\ LHFTInstaller \\发布\\ LHFAI.CAB。该
  数据已丢失。这个错误可能是由故障引起的
  计算机硬件或网络连接。请尽量保存此文件
  在其他地方。

Windows - Delayed Write Failed : Windows was unable to save all the data for the file \Vital\Source\Other\OCHSHP\Done07\LHFTInstaller\Release\LHFAI.CAB. The data has been lost. This error may be caused by a failure of your computer hardware or network connection. Please try to save this file elsewhere.

当它在Adobe发生,Visual Studio中,或Word,例如,没有造成任何伤害。当它发生时给我们的自定义应用程序的主要问题是(在dBASE文件到网络共享,将数据写入个C语言的应用程序。)

When it occurs in Adobe, Visual Studio, or Word, for example, no harm is done. The major problem is when it occurs to our custom applications (straight C apps that writes data in dBase files to a network share.)

从程序的角度来看,写入成功。它删除源数据,并进行到下一个记录。几分钟后时,Windows会弹出一个错误信息说,一个延迟写入发生,数据丢失。

From the program's perspective, the write succeeds. It deletes the source data, and goes on to the next record. A few minutes later, Windows pops up an error message saying that a delayed write occurred and the data was lost.

我的问题是,我们能做些什么为帮助我们的网络/服务器团队隔离并纠正问题(阅读,让他们相信这个问题是真实的。简单地告诉他们很多很多次也没有说服他们为还)和你有我们如何可以写,以避免数据丢失,有什么建​​议?

My question is, what can we do to help our networking/server teams isolate and correct the problem (read, convince them the problem is real. Simply telling them many, many times hasn't convinced them as of yet) and do you have any suggestions of how we can write to avoid the data loss?

推荐答案

写在Windows上,像任何现代操作系统,实际上并没有,直到OS得到解决它发送到磁盘。这是一个大的性能取胜,但问题(如你发现)的是,你不能在写的时候发现错误。

Writes on Windows, like any modern operating system, are not actually sent to the disk until the OS gets around to it. This is a big performance win, but the problem (as you have found) is that you cannot detect errors at the time of the write.

每个操作系统,做异步写入还提供了强制数据到磁盘的机制。在Windows上, FlushFileBuffers 或< A HREF =htt​​p://msdn.microsoft.com/en-us/library/17618685相对=nofollow> _提交功能会做的伎俩。 (一个是 HANDLE S,其他为文件描述符。)

Every operating system that does asynchronous writes also provides mechanisms for forcing data to disk. On Windows, the FlushFileBuffers or _commit function will do the trick. (One is for HANDLEs, the other for file descriptors.)

请注意,您的必须的检查每一个磁盘写的返回值,的这些同步函数的返回值,以确定上的数据做了它对磁盘。另外请注意,这些功能块,等待到达磁盘中的数据 - 即使你正在编写一个网络服务器 - 所以他们可能会很慢。不要给他们打电话,直到你真正需要的数据推到稳定的存储。

Note that you must check the return value of every disk write, and the return value of these synchronizing functions, in order to be certain the data made it to disk. Also note that these functions block and wait for the data to reach disk -- even if you are writing to a network server -- so they can be slow. Do not call them until you really need to push the data to stable storage.

有关详细信息,请参见 FSYNC()跨平台

For more, see fsync() Across Platforms.

这篇关于延迟写入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆