Re: [sqlite] Database corruption question

2016-07-20 Thread Tim Streater
On 20 Jul 2016 at 20:29, Richard Hipp  wrote: 

> On 7/19/16, Doug Nebeker  wrote:
>>  there is only one process using the database file (though multiple
>> threads, but they each have their own database handle).
>
> That threading mode (https://www.sqlite.org/threadsafe.html) are you
> using?  Are you sure that you are using the threading mode that you
> think you are using?  If you have not done so already, have you tried
> setting the threading mode to SERIALIZED to see if that clears your
> problem?

Is there a way to determine which threading mode is in use? I'm running the 
SQLite built-in to an IDE (Xojo) which uses SQLite 3.9.2. I couldn't see a 
pragma to use.

--
Cheers  --  Tim
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Database corruption question

2016-07-20 Thread Richard Hipp
On 7/19/16, Doug Nebeker  wrote:
>  there is only one process using the database file (though multiple
> threads, but they each have their own database handle).

That threading mode (https://www.sqlite.org/threadsafe.html) are you
using?  Are you sure that you are using the threading mode that you
think you are using?  If you have not done so already, have you tried
setting the threading mode to SERIALIZED to see if that clears your
problem?

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Database corruption question

2016-07-20 Thread Simon Slavin

On 19 Jul 2016, at 5:43pm, Doug Nebeker  wrote:

> Would it be possible for a file scanning process (anti-virus, backup, etc) to 
> grab hold of a database file at just the right moment, momentarily blocking a 
> write or delete, and causing corruption?

It might prevent the program from accessing the file in a way that the program 
interprets as corruption.  It should not actually corrupt the file on disk.  In 
that if you later reopen the file and run

PRAGMA integrity_check

it should not find a problem.

Does that command find a problem with your file ?  Once you have noticed the 
problem are you restoring to an uncorrupt version before continuing use of the 
file ?

> There is a greater chance that this is my bug or environmental than being in 
> SQLite, so I'm looking for anything I can do to decrease these occurrences.

Are you using any PRAGMAs after you open the file or special modes in your open 
command ?

Do you check the result codes returned by all commands run on the file to make 
sure they're SQLITE_OK ?  The command which notices that the file is corrupt is 
run sometime /after/ the command which corrupts it.  It's probably not the 
command which causes the corruption.

When you make changes to the file do you use _exec() or 
_prepare,_step,_finalize ?

Is the database short enough to allow you to run 'PRAGMA integrity_check' 
occasionally (when your app starts or quits ?  At 3am every morning ?) and 
check the result ?

Do not forget that your mention of 'environmental' includes the possibility of 
a faulty hard disk.

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users