[sqlite] journal files not always removed

2015-08-15 Thread Ashwin Hirschi

> With this new test case, I see that the -shm and -wal files are
> retained upon exit in read-only mode.

Great. Good to see other people are able to reproduce (some? of) the issue.

> But I also see that behavior dates back to 3.7.6 and maybe earlier. It  
> isn't something new.
> (Testing on Ubuntu).

How odd...[!] I've tested several 3.7.* and 3.8.* versions before posting  
and can only see things go wrong for 3.8.11 and after (on my Windows 10  
machine).

Also, are you sure you testing things right? I thought URI support was  
only added in 3.7.7... If that's true, your little script should actually  
throw an error for 3.7.6!

Ashwin.


[sqlite] journal files not always removed

2015-08-15 Thread Ashwin Hirschi

> Also, make sure that folder is not a shared resource or inside a shared  
> resource that is visible from any other network node or machine.
>
> This piece, describing the same symptom for Internet Explorer temporary  
> files, may help:
> https://support.microsoft.com/en-us/kb/814782

The folder is a regular one, alas.

> What happens when you make the DB, set WAL mode, do a Query, then wait 2  
> minutes doing nothing, then close the DB. Do the temp files still loiter?

I've tried your 2 minute pause suggestion, just to be sure. But the  
lingering journal files remain.

Also, I've added the folder to Windows Defender's exclusion list. There  
makes no difference either.

But, as I wrote in my previous post: older versions of SQLite *don't* show  
this behaviour (on the same machine)!

Ashwin.


[sqlite] journal files not always removed

2015-08-15 Thread Ashwin Hirschi

>> I've recently found SQLite doesn't always remove its journal files  
>> anymore.
>>
>> The issue seems to occur when opening WAL databases in read-only mode
>> (i.e. using SQLITE_OPEN_READONLY).
>>
>> A scenario to reproduce this (using version 3.8.11.1) looks like:
>>
>> 1. open a WAL database in read-only mode
>> 2. prepare & finalize a query
>> 3. close the database
>>
>> The "-shm" and "-wal" journal files are created during the prepare() in
>> step 2. But, after step 3, they're both still present.
>
> I am not able to reproduce the observed behavior on either Ubuntu,
> Win7, or Win8.  Please provide additional clues.

Here's a verbatim replay on my Windows 10 machine using the sqlite(3)  
commandline-tool (downloaded-but-renamed from sqlite.org):

=

c:\prj\demo>dir /b

c:\prj\demo>sqlite test.db
SQLite version 3.8.11.1 2015-07-29 20:00:57
Enter ".help" for usage hints.
sqlite> create table person(name text, email text);
sqlite> pragma journal_mode=wal;
wal
sqlite> .exit

c:\prj\demo>dir /b
test.db

c:\prj\demo>sqlite file:test.db?mode=ro
SQLite version 3.8.11.1 2015-07-29 20:00:57
Enter ".help" for usage hints.
sqlite> .tables
person
sqlite> .exit

c:\prj\demo>dir /b
test.db
test.db-shm
test.db-wal

=

The used folder is a regular, non-shared folder.

Running the same scenario using the official commandline tool for the  
older version 3.8.10.2 works exactly as expected (i.e. without any journal  
files remaining).

That last bit has me believing this is not related to the virus scanner  
(Windows Defender, btw.), but something must have changed in the SQLite  
code...

Ashwin.


[sqlite] journal files not always removed

2015-08-15 Thread Ashwin Hirschi

Hello,

I've recently found SQLite doesn't always remove its journal files anymore.

The issue seems to occur when opening WAL databases in read-only mode  
(i.e. using SQLITE_OPEN_READONLY).

A scenario to reproduce this (using version 3.8.11.1) looks like:

1. open a WAL database in read-only mode
2. prepare & finalize a query
3. close the database

The "-shm" and "-wal" journal files are created during the prepare() in  
step 2. But, after step 3, they're both still present.

If the database is opened in read-write mode, everything is fine. Lastly,  
I'm having the issue on a Windows 10 machine and am not currently able to  
test anywhere else...

So, can anyone else reproduce the above scenario?

Ashwin.

P.S. I've also checked some older SQLite versions. It looks like this  
unfortunate "non-cleanup" was introduced in 3.8.11.