Hi Deon, BINGO!!!!
I commented out this line of code in the Couchbase lite CBL_SQliteStorage.m source file and no more corruption!!!! // int err = sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, (SInt64)kSQLiteMMapSize, (SInt64)-1); It would be really awesome of this were added to the How to Corrupt an SQLite Database web page. Although it would probably be prudent if someone could verify these findings using my sample app and a patched version of Couchbase Lite. I'll post the solution to the Couchbase Lite Github issue that I started. I used to be able to reproduce the corruption with a single power cut. But now after commenting out that code, I'm unable to corrupt the database after about 6 or 7 power cuts. So I think it's safe to say that this problem is solved. Big thanks to you Deon. You just saved my bacon! Thank you so much. Brendan On Tue, Apr 18, 2017 at 3:20 AM, Deon Brewis <de...@outlook.com> wrote: > Yip. Tried that. At some point I had like 6 or 7 debug switches in the app > to try all manner of FULLSYNC/WAL/SYNCHRONOUS combinations. At the end it > was the MMAP_SIZE that did it. > > It's not like it was subtle - it's a dead on repro. I was able to repro > this by doing a power cycle 2 hours after shutting the app down. OSX didn't > seem to have any interest in flushing mmap files until you soft reboot the > machine. > > The last time I tried this though was on Yosemite and Mavericks and > whatever version of SQLITE was out at the time, so things may be different > now. But it would be the first place I would look for corruption on OSX > related to power cycling. > > - Deon > > -----Original Message----- > From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] > On Behalf Of Simon Slavin > Sent: Tuesday, April 18, 2017 1:57 AM > To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> > Subject: Re: [sqlite] Database corruption, and PRAGMA fullfsync on macOS > > > On 18 Apr 2017, at 9:50am, Deon Brewis <de...@outlook.com> wrote: > > > “From the OSX documentation: > > > > Note that while fsync() will flush all data from the host to the drive > (i.e. the "permanent storage device"), > > Deon, > > I’m not sure this is related, but have you seen > > <http://www.sqlite.org/pragma.html#pragma_fullfsync> > > <http://www.sqlite.org/pragma.html#pragma_checkpoint_fullfsync> > > ? > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users