_sopen (was: Corrupted database)
Riccardo Cohen <[email protected]> Thu, 15 Feb 2007 17:53:10 +0100
| Newsgroups | gmane.comp.db.metakit |
|---|---|
| Organization | articque |
| Message-ID | <[email protected]> |
Matt Oberle wrote: > If we had spent all this time and energy working together to implement > Pat's solution this would be a moot point. by the way, does someone knows about _sopen() ? -------- Original Message -------- Subject: Re: [Metakit] Corrupted database over network - WinNT Date: Wed, 14 Feb 2007 16:09:13 +0100 From: Riccardo Cohen <[email protected]> Organization: articque To: [email protected] Hi Jean-Claude, This is very clear, thank you. I really hope that vista corrected this wi= ndows bug. It is not the only bug with windows networking, but this one is a real pain. The problem now for us at least, is that we have many different way of us= ing metakit. sometimes we encapsulated in one of our class, wich make it easy to redef= ine a file strategy, but sometimes we access directly for performance reason, and th= ere are many places where we open a storage. Maybe I'm wrong, but there might be a very easy and effortless solution (= for developers that never have 2 C4_storage on the same file) : in c4_FileStrategy::DataOpen(), I tried to replace : fd =3D _wopen(wName, flags); by : fd=3D_wsopen(wName,flags,_SH_DENYRW); Unfortunately it did not work, but really if someone know something about= windows open() function, this could help many people. Thanks for any clue :) Jean-Claude Wippler wrote: > Thanks, Pat Thoyts for your detailed analysis and description of the=20 > workaround you found. >=20 > Let me summarize as follows: >=20 >> Metakit maps the file as >> a read-only memory mapping and when it saves it re-serializes into the >> underlying file. It then drops the current mapping and re-maps the >> file. What I observed was that when it re-mapped it got the original >> data and did not in fact re-map the newly written data at all. >=20 > In other words, Windows does not guarantee a consistent view of the dat= a=20 > it buffers for networked file systems: write something to a file, map i= t=20 > to memory *afterwards*, and apparently you can get stale data. >=20 > If MK were to use r/w maps and push its data through there, then=20 > presumably it would work. That will not work in the case when the file= =20 > has to be extended, though. Keep in mind that MK can write data to fil= e=20 > for which partially comes from the r/o map. Furthermore, MK maps r/o=20 > deliberately, because it prevents stray pointer writes from damaging a=20 > MK datafile. >=20 > So what we have today, is a design which works on Windows local disks,=20 > and on Unix/MacOSX both locally and on remote file systems (both NFS an= d=20 > SMB afaik). >=20 > [From: <[email protected]>] >> 1/ You confirm that metakit files have a serious design flaw that puts= =20 >> at risk our data when accessed through a network. >=20 > With all due respect, the "serious design flaw" is in Windows. Getting= =20 > that fixed is beyond our control. We can only hope that XP or Vista ge= t=20 > it right. >=20 >> 2/ You give indications on the nature of the corruption, and how to=20 >> prevent it. >=20 > Yes, and for that I am very grateful. In addition to Pat's most recent= =20 > post, more information can be found at=20 > http://www.equi4.com/pipermail/metakit/2005-August/002112.html >=20 > So the solution is to derive a c4_Strategy class which opens the file i= n=20 > exclusive mode. Pat has most generously handed everyone the solution o= n=20 > a silver platter. If you don't want to subclass c4_Strategy, then open= =20 > the file yourself and pass it to MK. If you never need concurrent=20 > readers, use CreateFile and always open with dwAccessMode set to 0, the= n=20 > turn it into a FILE* with freopen and pass it to MK. >=20 > I for one never use MK in r/w mode on remote file systems. Not just du= e=20 > to the above risks, but because locking also leads to all sorts of=20 > "Heisenberg" trouble. In my book, shared data use should use=20 > client/server solutions. That need only take a few dozen lines of code= ,=20 > depending on your tool choices. >=20 > -jcw >=20 >=20 > _____________________________________________ > Metakit mailing list - [email protected] > http://www.equi4.com/mailman/listinfo/metakit >=20 --=20 Tr=E8s cordialement, Riccardo Cohen ligne directe : 02-47-49-63-24 ------------------------------------------- Articque http://www.articque.com Moulin des Roches 37230 Fondettes - France tel : 02-47-49-90-49 fax : 02-47-49-91-49 _____________________________________________ Metakit mailing list - [email protected] http://www.equi4.com/mailman/listinfo/metakit --=20 Tr=E8s cordialement, Riccardo Cohen ligne directe : 02-47-49-63-24 ------------------------------------------- Articque http://www.articque.com Moulin des Roches 37230 Fondettes - France tel : 02-47-49-90-49 fax : 02-47-49-91-49 _____________________________________________ Metakit mailing list - [email protected] http://www.equi4.com/mailman/listinfo/metakit