title: Can't save core data managed object context when device passcode locked
body: <p>I'm creating a persistent store coordinator like this:</p>
  
  <pre><code>NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Mydatabase.sqlite"];
  NSError *error = nil;
  __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
        if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&amp;error])
  </code></pre>
  
  <p>The issue is that as soon as I issue a save on any managed object context it fails with the following error:</p>
  
  <pre><code>May 15 17:46:18 xx-iPad @WorkMail[2807] &lt;Warning&gt;: Core Data: annotation: -executeRequest: encountered exception = Updating max pk failed:  with userInfo = {
          NSSQLiteErrorDomain = 14;
      }
  May 15 17:46:18 xx-iPad @WorkMail[2807] &lt;Warning&gt;: Core Data: annotation: -executeRequest: encountered exception = Updating max pk failed:  with userInfo = {
          NSSQLiteErrorDomain = 14;
      }
  May 15 17:46:18 xx-iPad @WorkMail[2807] &lt;Warning&gt;: Core Data: annotation: -executeRequest: encountered exception = Updating max pk failed:  with userInfo = {
          NSSQLiteErrorDomain = 14;
      }
  
  </code></pre>
  
  <p>This is one error, another erorr is error 21 with an authorization denied error.</p>
  
  <p>When the passcode lock is not enabled, this does not occur. I am writing to core data from a background thread using a single persistent store coordinator.</p>