If you remove a busy check, does it output any statements? Do you have any custom functions/operations running so they could block sqlite in creating new statement?
2013/7/17 Loren Keagle <loren.kea...@braemarllc.com> > Hi everyone, > > I have an interesting locking problem that I'm wondering if someone can > help with some insight. > > I have a master database with some metadata, and several sub-databases to > store logging events. I have one reader object and one writer object that > attach to the sub-databases and encapsulate the read/write operations > respectively. > > I've found a very unexpected locking behavior with the attached databases > and exclusive transactions. One of my unit tests does the following: > > Begin EXCLUSIVE TRANSACTION; > insert several rows of data; > Commit transaction; > > Prepare query statement; > Iterate through one or more rows; > Reset statement; > > Attempt to begin transaction; <--- SQLITE_BUSY!!!! > Would like to write more here, but can't unless I close/open the > connection; > > I can't seem to figure out any reason why I can't create a new exclusive > transaction here, and I feel it must have to do with the fact that I have > attached to sub-databases (possibly the same sub-database) with my > reader/writer objects. This is single threaded and only database connection > (with attach/detach logic). > I have verified that all statements prepared by the connection are > properly reset - this is handled by my C++ wrappers, and any errors will > throw an exception. I even iterated through all of the current statements > with the following code immediately before my transaction failure, with no > results: > > sqlite3_stmt *stmt = NULL; > while ((stmt = sqlite3_next_stmt(db, stmt)) != NULL) > { > if (sqlite3_stmt_busy(stmt)) > { > const char* sql = sqlite3_sql(stmt); > std::cout << sql << "\r\n"; > } > } > > Can anyone think of a reason why attached databases would prevent entering > a second transaction? BTW, it doesn't seem to work with immediate > transactions either. If I remove the query, everything works fine. > > Thanks! > > > ________________________________ > This email, including any attachments and files transmitted with it, are > for the sole use of the intended recipient(s) to whom this email is > addressed, and may contain confidential and/or privileged information. Any > unauthorized review, use, disclosure or distribution is prohibited. If you > are not the intended recipient, please be advised that you have received > this email in error, and please contact the sender by reply email and > destroy all copies (including all electronic and hard copies) of the > original message. Thank you. > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users