Unable to create database connection with fatal error

I am using Couchbase Lite .NET on a Xamarin iOS mobile app. Occasionally, I’m getting a fatal exception where the database connection cannot be opened. Has anyone seen this? Or is this a matter of making sure the database connection and Manager object gets cleaned up, closed, and disposed of properly? Here’s the exception stack trace:

Couchbase.Lite.CouchbaseLiteException: Unable to create a storage engine, fatal error
at Couchbase.Lite.Database.Open () [0x00000] in :0
at Couchbase.Lite.Manager.GetDatabase (System.String name) [0x00000] in :0
Couchbase.Lite.CouchbaseLiteException: Unable to create a storage engine, fatal error

Hi @couchdb_user,

Could you paste the code you used to instantiate a database instance with the manager shared instance?


Heres’ the code. Should I be using Manager.SharedInstance instead of creating a new instance?

var dirInfo = Directory.CreateDirectory (_dbPath);
_manager = new Manager (dirInfo, Manager.DefaultOptions);
_database = _manager.GetDatabase(_dbPath);

Ok thanks, have you tried following this tutorial? https://github.com/couchbaselabs/mini-hacks/tree/master/kitchen-sync/xamarin/project
The first step is creating a db instance.


I looked at the tutorial. In my use case, I still need to specify the location of the database in the file system.

Is there a difference between using Manager.SharedInstance and then setting the directory on the shared instance versus creating a new instance of the Manager and passing in the directory to the constructor?

Again, my current implementation seems to work 99% of the time, but occasionally it is failing with a fatal error.

Ah ok then maybe it’s a bug, let’s confirm with @borrrden to know if you should open an issue on the .NET repo.

I’d have to know more about the circumstances under which it fails before I can determine whether it is a bug or not. The biggest reason I have seen this kind of thing happen is if the directory specified is not writable for some reason. What is _dbPath vs dbPath in this case?

This fatal crash seems to occur only if 1) the phone locks up and requires rebooting due to my app crashing or another completely unrelated app crashing or 2) my app (that has the couchbase database) crashes from some other un-related exception.

As for the directory where the database is getting created/saved, when running on iOS it is stored in the Library folder of the app sandbox/container.

The reason I asked that question is because I’m wondering if you are passing in a path to manager.GetDatabase() instead of simply a database name. I don’t think it would be related to think, but who knows. Without a reproduction case, the cause of this is not likely to be found unfortunately. Do you happen to be bundling a SQLite lib with your app instead of using the system one?