分析断电时文件操作flush不能写入硬盘数据丢失问题

一般写文件时,为了确保程序退出时也能把文件写到硬盘,都要在程序中加flush强制把内存缓存写到硬盘中,但这个flush只对内存缓存起作用,当遇到突然断电,还是不能保证已经写到物理硬盘上了。

现象:比如写一个文本文件a.txt,程序调用了flush,用notepad直接打开文件a.txt,可以看到flush的内容已经写到a.txt了,然后关掉notepad切断电源,然后再同上电源开机打开a.txt,可能会发现flush的内容又没有了,但这种情况不是每次都出现,跟flush和断电的时间间隔有关系。

原因:flush只是强制把内存缓存写到硬盘中,不能保证真正写入物理硬盘,一般物理硬盘内部都有一定的磁盘缓存,当看到a.txt的flush内容时可能只是磁盘缓存。

解决办法:应该说没有完美的解决办法,如果把磁盘缓存关闭,会大大降低整个系统包括操作系统的运行效率。一般大型服务器使用磁盘阵列等存储设备时磁盘缓存会更大,根本不能关闭,所以他们是通过UPS等备用电源来保障不出现断电问题,即使真的完全断电,他们也没有办法,只能丢失增量部分数据;另外,对于普通客户端系统,可以考虑备份机制,最好用追加的方式写文件,不要对整个文件改写,这样即使断电也只丢失增量部分数据。

140人评论了“分析断电时文件操作flush不能写入硬盘数据丢失问题”

  1. I would like to point out my respect for your generosity giving support to those people that really need assistance with this particular niche. Your real dedication to getting the solution around has been certainly functional and have consistently helped professionals much like me to realize their ambitions. Your amazing warm and helpful help entails a great deal a person like me and still more to my colleagues. Thanks a ton; from everyone of us.

  2. Thanks a lot for providing individuals with an extraordinarily nice opportunity to read from this blog. It really is very useful and stuffed with fun for me and my office co-workers to search your web site at a minimum thrice weekly to read through the latest issues you have. And indeed, I’m also certainly pleased with your brilliant creative concepts you serve. Selected 3 tips in this article are unquestionably the most impressive I have had.

  3. I simply desired to thank you very much once again. I do not know the things I might have gone through without the entire information discussed by you about such situation. It had been a real frightening difficulty in my view, nevertheless observing the very professional technique you handled that took me to cry for gladness. I am happy for the advice and even believe you recognize what a powerful job you are doing teaching the others through the use of your webpage. I am certain you have never come across any of us.

  4. I am glad for commenting to let you be aware of what a fantastic discovery my wife’s child undergone visiting your web site. She came to understand such a lot of things, which included how it is like to have a marvelous giving style to get folks clearly learn selected very confusing subject matter. You actually exceeded our own expectations. I appreciate you for giving those powerful, trustworthy, edifying and even cool tips about your topic to Gloria.

  5. I simply desired to appreciate you once more. I am not sure the things that I would’ve accomplished in the absence of those concepts documented by you relating to such field. This was a very intimidating concern in my circumstances, nevertheless discovering the specialized mode you processed the issue took me to leap with joy. Extremely thankful for your guidance and as well , pray you find out what a great job you happen to be undertaking teaching the others via your blog. More than likely you have never got to know all of us.

  6. A lot of thanks for your entire hard work on this web site. My aunt really loves setting aside time for research and it’s really easy to see why. A lot of people know all about the compelling method you make great tips and tricks via this blog and as well as inspire contribution from the others on that subject matter plus our favorite child is without a doubt studying a lot. Enjoy the remaining portion of the year. Your performing a powerful job.

  7. I precisely desired to appreciate you once more. I’m not certain the things I would have implemented without those tactics shared by you regarding my field. It was before the frightful issue in my position, but being able to see a skilled technique you handled that took me to leap with joy. I’m just happier for this assistance as well as hope that you are aware of a great job you are putting in training the rest all through your web blog. More than likely you haven’t encountered all of us.

  8. I as well as my buddies have already been reviewing the excellent techniques on your site while the sudden I got a horrible feeling I never thanked you for those secrets. All the boys had been so stimulated to read all of them and have really been taking pleasure in them. Appreciation for genuinely well accommodating and for picking this sort of important topics most people are really eager to learn about. Our own honest apologies for not expressing appreciation to you earlier.

  9. I precisely desired to appreciate you yet again. I’m not certain the things that I would have undertaken without the actual basics provided by you over such a problem. It had been a very frustrating scenario in my opinion, nevertheless viewing the specialized strategy you dealt with that took me to weep over contentment. Now i’m grateful for this work and then pray you are aware of a great job that you’re undertaking training the others via your web blog. I know that you have never got to know all of us.

  10. I truly wanted to write down a simple comment to say thanks to you for all of the remarkable ways you are writing at this website. My prolonged internet look up has at the end of the day been paid with extremely good facts to go over with my company. I ‘d repeat that we readers actually are undoubtedly blessed to be in a remarkable place with many special individuals with useful concepts. I feel really fortunate to have seen your entire website page and look forward to so many more pleasurable times reading here. Thanks again for all the details.

  11. I am only writing to let you understand of the fantastic discovery my wife’s child obtained studying your web page. She picked up a lot of details, not to mention what it is like to possess a marvelous coaching style to have the others completely know selected complex things. You truly did more than readers’ expectations. Many thanks for presenting these warm and friendly, trustworthy, revealing not to mention fun tips about the topic to Janet.

  12. Thank you for all your effort on this website. My mom really loves doing investigation and it is easy to see why. My spouse and i learn all about the lively medium you create both interesting and useful steps by means of this blog and even welcome response from some other people on that matter so our princess is truly being taught a whole lot. Have fun with the rest of the new year. Your doing a terrific job.

  13. I would like to show appreciation to you just for rescuing me from this type of predicament. Right after searching through the the net and finding methods which are not helpful, I assumed my life was well over. Living without the answers to the difficulties you’ve solved as a result of your good posting is a critical case, as well as those which may have in a negative way affected my career if I hadn’t noticed your web site. Your expertise and kindness in maneuvering every part was tremendous. I don’t know what I would’ve done if I had not come upon such a step like this. I am able to at this point look forward to my future. Thank you so much for the impressive and amazing guide. I will not hesitate to suggest your blog post to anyone who desires care on this issue.

  14. Thanks a lot for giving everyone an extremely pleasant opportunity to read from here. It is often so nice and also jam-packed with a good time for me and my office friends to visit your blog really three times weekly to study the newest guidance you will have. And lastly, I am also usually astounded with your impressive tips and hints served by you. Some 2 ideas in this post are particularly the most efficient we have ever had.

  15. This website online can be a stroll-by way of for all of the info you wished about this and didn抰 know who to ask. Glimpse right here, and also you抣l undoubtedly uncover it.

  16. Needed to draft you the very little remark in order to thank you over again on your spectacular information you’ve shared here. It is really tremendously open-handed with people like you to provide easily what exactly a lot of folks could possibly have offered for sale as an ebook to earn some profit for their own end, most notably since you might have done it if you desired. These thoughts also acted to be a easy way to fully grasp that someone else have the same dream similar to my personal own to understand much more in terms of this issue. I am sure there are several more pleasant times up front for individuals who take a look at your website.

  17. A lot of thanks for all of the hard work on this web site. Debby enjoys managing research and it is easy to see why. We hear all regarding the powerful method you offer very useful secrets through your blog and in addition cause participation from some others on the area then our favorite simple princess is always learning a whole lot. Enjoy the remaining portion of the new year. You’re carrying out a great job.

  18. I wish to voice my love for your generosity in support of persons who really need help with this one subject. Your very own commitment to getting the solution across was astonishingly effective and has made workers much like me to arrive at their pursuits. This warm and friendly information entails much to me and far more to my colleagues. Thanks a lot; from everyone of us.

  19. I actually wanted to jot down a quick remark to thank you for all the magnificent tips and hints you are showing at this site. My incredibly long internet investigation has now been honored with awesome details to exchange with my companions. I would repeat that many of us site visitors actually are truly fortunate to dwell in a decent community with so many awesome professionals with very helpful suggestions. I feel rather lucky to have seen your webpages and look forward to many more brilliant moments reading here. Thanks a lot again for a lot of things.

  20. I simply wanted to thank you very much once more. I am not sure the things that I would have carried out without the tricks shown by you about my concern. It previously was an absolute frightful situation in my circumstances, however , discovering the specialized form you managed it forced me to jump with gladness. Now i am happier for your assistance and as well , expect you really know what a powerful job you are always accomplishing training other individuals all through your webpage. I am certain you have never come across any of us.

  21. I as well as my friends were found to be following the good guides located on your website and then the sudden got a horrible suspicion I never thanked the website owner for those strategies. All the people happened to be consequently very interested to read them and have in effect very much been loving them. Thank you for really being so kind and then for picking these kinds of outstanding subjects most people are really desirous to learn about. My personal sincere apologies for not expressing gratitude to you earlier.

  22. Thanks a lot for giving everyone remarkably memorable possiblity to read from this website. It is usually so brilliant and also stuffed with a great time for me and my office peers to search your blog at the very least three times per week to see the latest guides you will have. And indeed, I’m actually fulfilled with your perfect tricks you serve. Some 4 points on this page are clearly the most effective we have all ever had.

  23. Howdy! I simply want to give an enormous thumbs up for the great info you could have right here on this post. I shall be coming back to your blog for more soon.

  24. I discovered your blog site on google and check a couple of of your early posts. Continue to maintain up the excellent operate. I just further up your RSS feed to my MSN Information Reader. In search of ahead to studying more from you afterward!?

  25. I used to be very pleased to search out this internet-site.I needed to thanks on your time for this excellent read!! I undoubtedly having fun with each little bit of it and I’ve you bookmarked to check out new stuff you weblog post.

  26. Oh my goodness! an incredible article dude. Thanks Nonetheless I am experiencing situation with ur rss . Don抰 know why Unable to subscribe to it. Is there anybody getting an identical rss drawback? Anyone who knows kindly respond. Thnkx

  27. Oh my goodness! an incredible article dude. Thank you Nevertheless I am experiencing situation with ur rss . Don抰 know why Unable to subscribe to it. Is there anyone getting similar rss drawback? Anybody who knows kindly respond. Thnkx

  28. Youre so cool! I dont suppose Ive learn anything like this before. So good to seek out any person with some unique ideas on this subject. realy thanks for beginning this up. this website is one thing that’s wanted on the web, someone with a little originality. helpful job for bringing one thing new to the internet!

发表评论

电子邮件地址不会被公开。 必填项已用*标注