I´m currently developing an upgrade of our current media storage (To store video/audio/metadata) for a surveillance system and I´m redesigning the recording structure to a more robust solution.
I need to create some index data of the data stored in data files, so I´m creating an index file structure, but I´m concerned with hard disks failure (Imagine if the power is cut during the write of the index file, it will become corrup since the data will most likely be half written). I already designed how the index will be stored, but my concern is relative to data corruption on power failure or disk failure
So, do anyone know techniques to avoid data corruption upon writting?
I already searched a little and found no good solutions, one solution was to create a log of everything that is written to the file, but then I will have many more I/Os per second (I´m concerned with the amount of I/Os per second as well, the system should perform the least as possible).
What I came up with was to duplicate sensitive data in the index file along with a timestamp and checksum fields. For example:
Field1 Field2 Field3 Timestamp Checksum
Field1 Field2 Field3 Timestamp Checksum
So, I have the data written twice, if when I read the file, the first set of fields is corrupted (Checksum doesn´t match), I have the second set of fields that should be OK. I believe that corrupion happen when the writting if stopped in the middle, so, for example, when the software is writting the first set of fields and the power failure, the second set is still intact... if the power failures while the second set is being written, the first one is already intact.
What do you guys think of this solution? Does it avoid data corruption?
BTW, I can´t use any kind of database for this kind of storage or transactional NTFS due to the restrictions to deploy a system with transactional NTFS
Any ideas are welcome, thanks!