Subject Re: [firebird-support] Forced writes on Linux?
Author Ann Harrison
On Fri, Jan 15, 2016 at 5:15 AM, Tim Ward tdw@... [firebird-support] <firebird-support@yahoogroups.com> wrote:
I know the folklore around forced writes

- turning forced writes on is safer

Not exactly folklore.  Firebird doesn't have a journal but instead depends on careful writes to keep the database constantly consistent.  After a crash - system or database - there's no recovery process.  The database is available instantly.  

The basic principle of careful write is writing data before pointers. When adding data, the page with the data is written before the page that points to it.  When removing data, the pointer is cleared before the data.  This principal applies to internal structures like pointers as well as records and indexes.  If you allow the operating system to write pages in its preferred order, the database on disk may be inconsistent.  As long as nothing goes wrong, the state of the database on disk isn't an issue.  At one time, Windows didn't flush its page cache until a file was closed, leading to losing hours or days of work.  

What's different now is that machines are both faster and more reliable.  If nothing crashes, careful write doesn't matter.

 
- turning forced writes on is slower
- the safety bit is much more of an issue with Windows than with Linux,
to the extent that it used not to work on Linux and nobody noticed for
years.

But I haven't found any actual, y'know, like, data, evidence, so on.
Things like (with reference to Linux, I'm not interested in Windows):

(1) Is there any data about how much slower it is, eg has anyone done
any benchmark runs on their systems? - I've found just one blog entry
somewhere with a number ("up to three times slower") but without any
(published) data behind it.

I wouldn't particularly trust benchmarks that are more than three years old. 

(2) Is there any evidence about how much safer it is? Statistics on
corruptions with and without? Analysis of individual database corruption
events showing whether turning on forced writes would or would not have
prevented the corruption event?

The evidence I have is too old to be relevant, so I can offer only theory, not
practice.  In theory, there should be no difference...

Cheers,

Ann