CubeSQL connection lost before commit

I know maybe I should write this straight to Marco at SQLabs, but I thought posting it here maybe I get a faster response…

The question is… What happens if my app crashes or gets an exception after a ‘begin transaction’ was done but before commiting it ?

Will it lock the DB ? How should I protect from this scenario ?

(Maybe just throw a commit in case of an unhandled exception ??)

Thanks
Roman

my understanding, it that is all in a journal file and if it “crashs” that file vanishes and it is as if nothing happened
but when the transaction completes, that journal file is “commited”

This would be easy to test. Start a transaction, kill your app running in debug mode, see what happens.

But I have code in the unhandled exception handler, so the app does not vanish if an unhandled exception occurs… it just cuts the process it was doing…

I think have read that uncommited write operations DO lock the db…

I’ll give it a try…

but they are not uncommited writes… you haven’t written them yet… thats the purpose of “transaction”

Once you “BEGIN TRANSACTION”, the db will be locked on CubeSQL for other writers, as there can be only 1 concurrent writer.
So if you handle exceptions, you’ll have to “ROLLBACK” or “COMMIT”.
Another way of “unlocking” is of course to close the connection (or let the database-object go out of scope so that it closes / or quit the application entirely).

try BEGIN TRANSACTION 'all ok COMMIT catch error 'we don't want to commit this unfinished transaction ROLLBACK end try