On 18 Apr 2017, at 6:46pm, Jens Alfke <j...@mooseyard.com> wrote:

> This is a statement about hard disk controller firmware and is true for any 
> OS. (I used to work for Apple, and corresponded with filesystem architect 
> Dominic Giampaolo about this back in the day.) Some disk controllers don’t 
> flush all cached data to the platters when told to flush, apparently to boost 
> benchmark scores. Darwin has a FULLFSYNC command (an option to ioctl) that 
> triggers an expensive full reset of the disk controller, which does produce a 
> full flush.

That’s what "PRAGMA fullfsync" is about.  From what I can see, SQLite uses it 
in a way that Apple’s documentation says should work.  But it seems that 
despite being all Apple says is necessary, it’s not doing the job.  Note, 
however, that SQLite documentation says that the default value for this flag is 
off, even when running on a Mac.

> [snip]
> 
> This doesn’t seem like it would be specific to memory-mapped I/O, though. 
> Darwin has a universal buffer cache (like many other kernels) so 
> memory-mapped writes and ordinary file writes are treated the same way by the 
> filesystem cache.

Need to check Darwin source code.  The documentation for some operating systems 
considers memory-mapping to be special, and separate from normal file access.  
So things which configure how normal file access is done sometimes don’t apply 
to memory-mapped file access or memory-mapped I/O in general.  Power-loss is a 
good test of memory-mapped changes and problems with them.

> Of course it’s possible there’s some kind of OS bug involved here; if so, it 
> seems pretty serious. I’ll be glad to file a bug report with Apple if it 
> turns out to be so.

People who’ve posted things connected to this don’t tend to mention that 
they’ve set "PRAGMA fullfsync = ON".  It’s the sort of thing you’d only know to 
do after significant debugging.  Maybe they’re not doing it and that’s the 
cause of their problems.

Simon.

Obligatory Disclosure: I’m a Macintosh specialist, a Macintosh programmer, and 
I know a lot about computer security.  But this stuff is at the edge of my area 
of competence.  I’ve never worked for Apple and don’t know the tiny details of 
this stuff.  Don't depend on the things I write here for critical decisions.  
If you’re a member of Apple’s Developer Programme perhaps you should get Apple 
involved.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to