On 12/9/15, R Smith <rsmith at rsweb.co.za> wrote:
> One of our systems suddenly started to play up after upgrading to 3.9.2
> from 3.8.8 (so I am not sure exactly when the oddity was introduced).
>
> SQLite:
> v 3.9.2 linked on WIndows (various versions) in a 32 bit application via
> the exact 32bit DLL published on the downloads page on sqlite.org.
>
> The error:
> During an update to an attached DB, the statement fails and reports
> "Disk I/O Error" and leaves a hot journal (even though the statement
> wasn't in an explicit transaction).
>

We can make a script to do this.  And we get this error (when we
enable logging - https://www.sqlite.org/errlog.html - which you really
should do too).

{SQLITE_IOERR_DELETE {os_win.c:39624: (32) winDelete(C:\Users\drh\sqlite\sqlite\
test2.db-journal) - The process cannot access the file because it is being used
by another process.}

The problem is that one connection is trying to delete the journal
file that the other connection is holding open.

The thing is this:  We can reproduce this going all the way back to
version 3.8.0 (which is as far back as I looked.)  So I don't know how
you managed to get it working on your 3.8.8 version.

To reproduce this with a script, to "nmake /f makefile.msc
testfixture.exe" then run "testfixture x7.txt" where you have filled
the file x7.txt with the following text:

file delete -force test.db test.db-journal
proc dolog {args} {
  puts [list $args]
  flush stdout
}
sqlite3_shutdown
test_sqlite3_log dolog
sqlite3 db test.db
puts [db eval {SELECT sqlite_source_id()}]
db eval {
  PRAGMA journal_mode=DELETE;
  CREATE TABLE t1(x);
}
file delete -force test2.db test2.db-journal
sqlite3 db2 test2.db
db2 eval {
  PRAGMA journal_mode=TRUNCATE;
  CREATE TABLE t2(y);
  INSERT INTO t2(y) VALUES(1),(2),(3);
}
db eval {
  ATTACH 'test2.db' AS TmpDB;
  SELECT rowid, y FROM TmpDB.t2;
} x {
  puts [unset -nocomplain x(*); array get x]
}
puts "***********************"
db2 eval {
  INSERT INTO t2(y) VALUES(3),(4),(5);
}
db eval {
  UPDATE TmpDb.t2 SET y=y+100;
  SELECT rowid, y FROM t2;
} x {unset -nocomplain x(*); puts [array get x]}
puts "***********************"
db2 eval {
  SELECT rowid, y FROM t2;
} x {unset -nocomplain x(*); puts [array get x]}
db close
db2 close


-- 
D. Richard Hipp
drh at sqlite.org

Reply via email to