I'm building a prototype of an app where persistent store uses SQLite via AFP on a "server" machine (the same LAN). However, I can't connect to the store from 2 different instances of my app.
I set SQLite pragma setting (related to locking) on persistent store coordinator like this:
NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
NSMutableDictionary *pragmaOptions = [NSMutableDictionary dictionary];
[pragmaOptions setObject:@"NORMAL" forKey:@"locking_mode"];
NSDictionary *storeOptions = [NSDictionary dictionaryWithObject:pragmaOptions forKey:NSSQLitePragmasOption];
if (![coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:storeOptions error:&error]) {
[[NSApplication sharedApplication] presentError:error];
return nil;
}
and error message I'm getting when trying to connect to the store from 2nd client (i.e. when the 1st one is already successfully connected) is:
ERROR: sqlite database is locked because it is in use by another host that holds a host-exclusive lock on .../TestDBApp.storedata; this host UID... cannot override the host-exclusive lock until the other host UID... releases its locks on .../.TestDBApp.storedata-conch
Am I doing something wrong?
Is accessing the same store from 2 clients possible with Core Data and SQLite?
Is this a bug in Core Data and/or SQLite API?