Jim Borden
2016-09-29 07:39:04 UTC
I found the following snippet from https://www.sqlite.org/lockingv3.html
➢ The SQL command "COMMIT" does not actually commit the changes to disk. It just turns autocommit back on. Then, at the conclusion of the command, the regular autocommit logic takes over and causes the actual commit to disk to occur.
Does that mean that the actual commit happens after the execution of “COMMIT” (i.e. it is in a sense asynchronous)?
Could that explain some odd behavior that I am seeing? I have two connections to a database file and reports that writing to one and then immediately querying from another causes the second connection to show the entry as missing. I was working under the assumption that after COMMIT finished that everything would be visible to all connections but is this a false assumption? The suspiciousness is also due in part to this only happening when:
1) There are more than ~1200 entries in the table
2) The conclusion of the write and the read happen <= ~500ms apart (not very accurate timing, going by log timestamps)
Further queries after the initial one return the entry as expected. Also, if either of the above conditions are not met then even the initial one is ok. The database file is operating in WAL mode on version 3.8.10.2 (technically it is SQLCipher) with no pragma modifications. All access is on the same physical disk coming from the same process, but with two different threads (one writing and one reading). Really I’d just like to know if I’m barking up the wrong tree here trying to explain why this odd behavior occurs.
Jim Borden
Software Engineer
***@couchbase.com
➢ The SQL command "COMMIT" does not actually commit the changes to disk. It just turns autocommit back on. Then, at the conclusion of the command, the regular autocommit logic takes over and causes the actual commit to disk to occur.
Does that mean that the actual commit happens after the execution of “COMMIT” (i.e. it is in a sense asynchronous)?
Could that explain some odd behavior that I am seeing? I have two connections to a database file and reports that writing to one and then immediately querying from another causes the second connection to show the entry as missing. I was working under the assumption that after COMMIT finished that everything would be visible to all connections but is this a false assumption? The suspiciousness is also due in part to this only happening when:
1) There are more than ~1200 entries in the table
2) The conclusion of the write and the read happen <= ~500ms apart (not very accurate timing, going by log timestamps)
Further queries after the initial one return the entry as expected. Also, if either of the above conditions are not met then even the initial one is ok. The database file is operating in WAL mode on version 3.8.10.2 (technically it is SQLCipher) with no pragma modifications. All access is on the same physical disk coming from the same process, but with two different threads (one writing and one reading). Really I’d just like to know if I’m barking up the wrong tree here trying to explain why this odd behavior occurs.
Jim Borden
Software Engineer
***@couchbase.com