Hello, fellow developers. 

Recently we performed a lot of test with ZFS and Sqlite and long story short: 
we came up with a conclusion 
that it is safe to disable fsync() to keep database consistent (though not 
durable), even in case of power failure. 
So we decided to stck with? 'PRAGMA synchronous = OFF' since durability does 
not concerns us very much. 

But we have one specific use-case whe 'master' database is first opened and 
then 'slave' database is being attached. 
When some updates? are made to 'slave' and 'master' we still see fsync() being 
called for 'slave', its journal and 
their directory but not for 'master' nor for 'master's journal. 

We perform these steps: 

(1) open 'master' 
(2) execute 'PRAGMA synchronous = OFF;' 
(3) attach 'slave' 
(4) do updates 

and see fsync()s. 

Even when we insert 'PRAGMA synchronous = OFF;' after (3): 

(1) open 'master' 
(2) execute 'PRAGMA synchronous = OFF;' 
(3) attach 'slave' 
(3.1) execute 'PRAGMA synchronous = OFF;' 
(4) do updates 

nothing changes: 'slave', its journal and thier directory are still fsync()-ed. 

On the other hand if we change our steps to 

(1) open 'master' 
(2) execute 'PRAGMA synchronous = OFF;' 
(3) attach 'slave' 
(3.1) execute 'PRAGMA slave.synchronous = OFF;' 
(4) do updates 

i.e. explicitly specify 'slave' before synchronous pragma, both 'slave' and its 
journal stop being fsync()-ed. 
However there is still fsync() for directory that we would really like to 
avoid. 

So the questions are: 

Is <http://www.sqlite.org/pragma.html#pragma_synchronous> doc page is outdated 
and 'synchronous' pragma is now set for each databse separately? 

How to avoid fsync() for directory? 
I know that it is 'not safe'. But same can be said about not syncing journal 
and/or database file when 'PRAGMA synchronous = OFF;' is set. 
Is there a specific reason for keeping fsync() for directory? 

Seqlite version that we use is: sqlite3-3.8.7_1 

Thanks, 
Paul 

Reply via email to