martin troxler wrote:
We use Metakit on a embedded linux device that uses a EXT3-
formatted compact flash card. Because we have to face the problem
of sudden power fail, I wrote some tests that reset the device
(hardware reset!) while writing to the database (adding rows and
full commit)
I browsed the mailing list and found your recovery how-to
(truncating the file to the size given by bytes 4..7).
But in my case the file is smaller than written at those bytes 4..7 !!
I am using Metakit 2.4.9.5, because I was hoping that those changes
would help me, too.
Any help would be appreciated
You are going to have to force fsyncs (and be sure they work on your
platform) to guard against power outages. The proper place to do
this is in c4_FileStrategy::DataCommit (src/fileio.cpp), after the
fflush. There is no portable way to do this. The more involved but
cleaner way to do this is to create a derived class and override
DataComit (you can call the base class and do the fsync afterwards if
_failure == 0.
This change will force two fsyncs on each commit, protecting start
and the end of the commit as is need for full safety (DataCommit gets
called twice on each MK commit). The file damage you witnessed is
caused by your device not performing writes in the order they are
issued - with an fsync (again, making sure these really go all the
way to the CF card!) the essential two writes will be ordered as
needed to guarantee stable storage.
-jcw
_____________________________________________
Metakit mailing list - Metakit@equi4.com
http://www.equi4.com/mailman/listinfo/metakit