"Failed to run transaction" on CBLite

Hi there,

I’m having a bit of trouble with some simple document updates/deletes within Couchbase mobile (I’m on 1.3):

Currently when trying to delete a record I get this ambiguous non-error telling me “Failed to run transaction”. Later I will update the same record with different details and it’ll tell me I’ve tried to do a duplicate insert (I’m guessing that’s from invoking create instead of update), but also that there’s conflicting revisions of the document.

However, you can see from the image below that when I attempt to view the Document’s Deleted and Conflicting revisions property after invoking my Delete, I get False for Deleted and 0 conflicting revisions.

Is there somewhere else I can drill down into this error/logs perhaps?

I’ll continue investigating the overall workflow at play here as it was implemented by another dev, but I’d still like to be able to get a bit more visibility on quite what is going wrong here.

Regards,
/Ant

It looks like you are running 1.2.1 or below. Unfortunately the logging for that version is pretty bad. I’d suggest moving to 1.3 if possible because the logging has been completely overhauled.

EDIT I just saw now that you claim to be on 1.3, but your logs suggest otherwise. Make sure you don’t have any stale assemblies.

Hi Borrrden,

This screenshot might of been before I did the 1.3 update (I upgraded this afternoon), but I’ve since run a full clean rebuild and clear on the iOS simulator, and the same problem persists.

2016-08-12 16:34:43.479 MinervaiOS[95022:7721320] [Verbose] About to exit CheckSynchronisationState Thread started: <Thread Pool> #9 Thread started: <Thread Pool> #10 2016-08-12 16:34:52.978 MinervaiOS[95022:7721320] SqliteCouchStore: Failed to run transaction Thread finished: <Thread Pool> #5 2016-08-12 16:35:08.736 MinervaiOS[95022:7721320] [Verbose] Deleted document with local key user-record-Admin@agilityworks.co.uk 2016-08-12 16:35:08.737 MinervaiOS[95022:7721320] [Information] User roles record deleted Thread finished: <Thread Pool> #4 Thread finished: <Thread Pool> #10 2016-08-12 16:35:23.326 MinervaiOS[95022:7721320] [Verbose] Created unknown document with local key user-record-Admin@agilityworks.co.uk 2016-08-12 16:35:23.741 MinervaiOS[95022:7721320] SqliteCouchStore: Duplicate rev insertion user-record-Admin@agilityworks.co.uk / 1-27456347fa6f1f152bdc24b3e5439bdd Thread finished: <Thread Pool> #3 2016-08-12 16:35:43.966 MinervaiOS[95022:7721320] SqliteCouchStore: Error executing SQL query 2016-08-12 16:35:43.968 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.968 MinervaiOS[95022:7721320] System.Threading.ThreadAbortException: 2016-08-12 16:35:43.968 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.968 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.968 MinervaiOS[95022:7721320] at (wrapper managed-to-native) System.Threading.Monitor:Exit (object) 2016-08-12 16:35:43.969 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.969 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.969 MinervaiOS[95022:7721320] at System.Threading.ManualResetEventSlim.Wait (Int32 millisecondsTimeout, CancellationToken cancellationToken) [0x001ad] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/threading/ManualResetEventSlim.cs:636 2016-08-12 16:35:43.969 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.969 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.969 MinervaiOS[95022:7721320] at System.Threading.Tasks.Task.SpinThenBlockingWait (Int32 millisecondsTimeout, CancellationToken cancellationToken) [0x00039] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:3326 2016-08-12 16:35:43.970 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.970 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.970 MinervaiOS[95022:7721320] at System.Threading.Tasks.Task.InternalWait (Int32 millisecondsTimeout, CancellationToken cancellationToken) [0x00042] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:3265 2016-08-12 16:35:43.970 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.970 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.971 MinervaiOS[95022:7721320] at System.Threading.Tasks.Task1[TResult].GetResultCore (Boolean waitCompletionNotification) [0x0000b] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/threading/Tasks/Future.cs:556
2016-08-12 16:35:43.971 MinervaiOS[95022:7721320]
2016-08-12 16:35:43.971 MinervaiOS[95022:7721320]
2016-08-12 16:35:43.971 MinervaiOS[95022:7721320] at System.Threading.Tasks.Task1[TResult].get_Result () [0x00000] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/threading/Tasks/Future.cs:532 2016-08-12 16:35:43.971 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.971 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.971 MinervaiOS[95022:7721320] at Couchbase.Lite.SqlitePCLRawStorageEngine.RawQuery (System.String sql, System.Object[] paramArgs) [0x0005c] in /Users/borrrden/Development/couchbase-lite-net/src/StorageEngines/SQLiteCommon/storage.sqlite.common/src/SqlitePclRawStorageEngine.cs:433 2016-08-12 16:35:43.972 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.972 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.972 MinervaiOS[95022:7721320] at Couchbase.Lite.SqlitePCLRawStorageEngine.IntransactionRawQuery (System.String sql, System.Object[] paramArgs) [0x00041] in /Users/borrrden/Development/couchbase-lite-net/src/StorageEngines/SQLiteCommon/storage.sqlite.common/src/SqlitePclRawStorageEngine.cs:368 2016-08-12 16:35:43.972 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.972 MinervaiOS[95022:7721320] 2016-08-12 16:35:43.972 MinervaiOS[95022:7721320] at Couchbase.Lite.Store.SqliteCouchStore.TryQuery (System.Func 2 action, Boolean readUncommit, System.String sqlQuery, System.Object[] args) [0x00008] in /Users/borrrden/Development/couchbase-lite-net/src/StorageEngines/SQLiteCommon/storage.sqlite.common/src/SqliteCouchStore.cs:310 2016-08-12 16:35:43.973 MinervaiOS[95022:7721320]

The above is a more up-to-date log, where I’ve let it run past the call to create.

That ThreadAbortException is troubling. Are you aborting threads anywhere?

Not manually no, these occur after allowing the code to run freely, normally it’s the result of a parent tasking timing out and passing a cancellation token down to the child, that being said this is all buried somewhere in the CBLite dll’s, so I’m taking shots in the dark.

Regards,
/Ant

Did you upgrade to the version on nuget.org? I don’t see the “Failed to run transaction” log statement on SqliteCouchStore in the 1.3 source and the line numbers in the exception are not what I expect. You should see a statement at the beginning of the log indicating the version.

I did indeed, I’ve noticed there’s another project still with references to 1.2, but the dll that interacts with CB has been updated to 1.3.

I’m updating the other project now, but I’ve also made logical code changes as I think there was a misunderstanding of the logical workflow for the task being accomplished here, that might of aided in the manifestation of the bugs in the first place.

I’ll update the thread on Monday with my findings :slight_smile:

I’ve updated the underlying library, but I’m now unable to make headway as I’m getting:

“SQLite: This store does not support encryption”.

However my code is almost the exact same as the CB 1.3 mobile documentation:

var manager = Manager.SharedInstance;

        var options = new DatabaseOptions()
        {
            Create = create,
            EncryptionKey = new SymmetricKey(pin + _options.Password, _options.Salt, _options.Rounds),
            StorageType = StorageEngineTypes.SQLite
        };

        var db = manager.OpenDatabase(_databaseName, options);
        if (db != null)
        {
            db.Changed += CouchbaseDB_Changed;
            CouchbaseDB = db;

            IsReady = true;
        }

I’ve tried setting the storageType to be “SQLCipher” on a guess that it might just not be listed in the enum, but the docs state that as long as the reference to SQLCipher is there, it should work against SQLite. This occurs when the create flag is equal to true after a fresh wipe of my simulator.

Regards,
/Ant

You need to register the SQLCipher plugin as of 1.3

Ah, I did see a bit of information on this, but it only mentioned the base SQLite plugin register (which I did), was unaware I’d have to do the same for SQLCipher as it wasn’t in the docs here: http://developer.couchbase.com/documentation/mobile/1.3/develop/guides/couchbase-lite/tech-notes/cbl-encryption/index.html

If someone could update the relevant info docs on the CB site, that might save future devs some time! :wink:

Regards,
/Ant