From: Francesco D. D. <ke...@li...> - 2005-10-08 08:08:39
|
Hi, i've a question: Under certain circumstances, i can running into corrupting of .h5 file, for instance when machine crash, power failure, etc... , causing lost of all data (i'm working into gigabytes files). Perhaps this is an hdf5 question, but i would like to know in what manner do you manage this in practice. Some considerations: 1) Copying/rsyncing the file before writing is possible but is very very slow on big files. 2) Truncating the file to size before writing doesn't resolve the problem, hdf5 remains corrupted (the header is changed, hdf5 isn't pure append file) It's possible to implement a recovery/checkpoint system? I've noticed that hdf5 uses some headers in file (http://hdf.ncsa.uiuc.edu/HDF5/doc/H5.format.html), if i try to save (i need to study hdf5 file format) headers before writing, for instance in a master register/file, i can achieve recovery? I would like to write some hdf5/pytables extension to recovery corrupted files, in your opinion it's wasted work? It's obvious that this is possible only if i append data, because if i change rows, i need to track also rows changes in file (more difficult task). Thanks for your job, Francesco |
From: Norbert N. <Nor...@gm...> - 2005-10-08 09:15:44
|
Hi there, I did some web-research on the topic a little while ago, but I could not find any details about it: As it seems, the HDF5 library does not take any precautions about possible power failures. Modern database systems usually have a concepts of "atomic operations" and "journalling" that protect the data against corruption. HDF5 does not provide this, so pytables is out of luck. There is no perfectly safe way of handling a HDF5 file. What I usually do is to limit the chance of breaking by doing write operations all at once at the end of a big calculation loop and flush the data immediately. Of course, this only makes sense for programs (like mine) where outputting data takes a negligible fraction of the total computation time. The chance that the program breaks in this short while is negligible. Alternatively, it might be possible to carefully select the data structures in such a way that a write operation never changes the control data in the file. (i.e. no dynamic data structures, no growing tables, etc.) this way, it should be possible to write the data in such a way that the file is in a sane conditition at any point of time, no matter where it breaks half-way in an operation. Data compression should probably be avoided in any case in such a situation. Of course, in either way, you throw away much of the power of pytables, but unfortunately, that's the price you have to pay for safety. Greetings, Norbert Francesco Del Degan wrote: >Hi, i've a question: > >Under certain circumstances, i can running into corrupting of .h5 file, >for instance when machine crash, power failure, etc... , causing >lost of all data (i'm working into gigabytes files). > >Perhaps this is an hdf5 question, but i would like to know in what manner >do you manage this in practice. > >Some considerations: > >1) Copying/rsyncing the file before writing is possible but is very very >slow on big files. >2) Truncating the file to size before writing doesn't resolve the problem, >hdf5 remains corrupted (the header is changed, hdf5 isn't pure append file) > >It's possible to implement a recovery/checkpoint system? > >I've noticed that hdf5 uses some headers in file >(http://hdf.ncsa.uiuc.edu/HDF5/doc/H5.format.html), >if i try to save (i need to study hdf5 file format) headers before >writing, for instance >in a master register/file, i can achieve recovery? > >I would like to write some hdf5/pytables extension to recovery corrupted >files, in your >opinion it's wasted work? > >It's obvious that this is possible only if i append data, because if i >change >rows, i need to track also rows changes in file (more difficult task). > >Thanks for your job, >Francesco > > > > >------------------------------------------------------- >This SF.Net email is sponsored by: >Power Architecture Resource Center: Free content, downloads, discussions, >and more. http://solutions.newsforge.com/ibmarch.tmpl >_______________________________________________ >Pytables-users mailing list >Pyt...@li... >https://lists.sourceforge.net/lists/listinfo/pytables-users > > > > |
From: Francesc A. <fa...@ca...> - 2005-10-10 18:54:33
|
Hi Francesco, A Dissabte 08 Octubre 2005 10:06, Francesco Del Degan va escriure: > I would like to write some hdf5/pytables extension to recovery corrupted > files, in your opinion it's wasted work? Well, I can't tell you exactly if this is hard or not, because I simply don't know too much about the intrincacies of HDF5 in this regard. You should look at: https://sourceforge.net/mailarchive/forum.php?forum_id=3D13760&max_rows=3D2= 5&style=3Dnested&viewmonth=3D200409 for some messages exchanged about this issue back in September 2004. If you read them, you will see that the main problem is the existence of caches in the HDF5 library for both data and metadata. Those caches can be disabled for bettering the chances that the file does not get corrupted, but indeed, at the cost of speed. In any case, the recomendation by Norbert Nemec of flushing frequently is good, but of course, you don't have to expect too much of it. > It's obvious that this is possible only if i append data, because if i > change rows, i need to track also rows changes in file (more difficult > task). The other suggestion by Norbert is intriguing and perhaps worth to try it up. If you book a big space for your data, and then start to save rows until the dataset is full, I'd bet that you will be minimizing the changes of corrupting the metadata headers. CArray objects already let's you to book a large chunk of space in file for your data. So, what Norbert proposes is doing that (i.e. setting the metadata) and fill this space afterwards; if something goes wrong later on, perhaps some data would be lost, but the file might still be readable. Despite that Table ojects does not support (yet) booking large amounts of space without feeding it with data, I suggest you to try CArrays first in order to see if what I said before actually minimize the probability of corruption. If it does, then, it's just a matter of allowing Table objects to support that capability as well. > Thanks for your job, You are welcome! =2D-=20 >0,0< Francesc Altet =A0 =A0 http://www.carabos.com/ V V C=E1rabos Coop. V. =A0=A0Enjoy Data "-" |