cloudant / CDTDatastore

Cloudant Sync iOS datastore library.
Apache License 2.0
175 stars 53 forks source link

500 createDocumentFromRevision #453

Closed rashenoy closed 2 years ago

rashenoy commented 5 years ago

Bug Description

Getting database error 500

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

Creating documents using createDocumentFromRevision occasionally gives 500 Database error! It is not like it doesnt create documents at all. But it gives me this callback sometimes. It is neither that no documents are created once I get this callback. I have seen documents getting created after this callback for new documents. The names of all of these documents have a specific pattern and I am able to create these in general. The folder structure and DB exists locally and is not tampered with.

What are all possible causes for getting the error 500 ? It just says "500 Database error" in localizedDescription. Sometimes I also see this error when you do compactWithError.

Code Snippet: NSString eventDocName = @"event_19FCE3BB-C5B6-4FE4-A7FC-EED6251D5FD3_2019-03-04-20-12-29-869" _mDocRev = [[CDTDocumentRevision revision] initWithDocId:eventDocName revisionId:nil body:json attachments:nil]; DDLogVerose(@"opening new mDocRev with docId= %@ revId=%@", _mDocRev.docId, _mDocRev.revId); NSError error; [_mDatastore createDocumentFromRevision:_mDocRev error:&error]; if(error){ DDLogError(@"createDocumentFromRevision %@", [error localizedDescription]); }

2. What you expected to happen

Each time I create a document, it should create one.

3. What actually happened

"500 Database error!"

Environment details

Installed using Pod.

ricellis commented 5 years ago

This suggests there is an error from the underlying SQLite database; the 500 Database error! is the default unless we identify something more specific (e.g. disk full). To debug this further we'd need to know what went wrong in SQLite - I believe these types of errors are logged to NSLog via the FMDB/sqlite3 dependency. If you can find the underlying SQLite error in the logs that would be helpful.

rashenoy commented 5 years ago

Thanks for the resoonse. Is there way to enable these logs using lumberjack so it is automatically routed to a log dump that is setup already in my project? Please give me specific instructions as to what/how to enable these logs using lumberjack and I will put it.

Best Regards Ravi

On Fri, Mar 8, 2019, 9:29 PM Rich Ellis notifications@github.com wrote:

This suggests there is an error from the underlying SQLite database; the 500 Database error! is the default unless we identify something more specific (e.g. disk full). To debug this further we'd need to know what went wrong in SQLite - I believe these types of errors are logged to NSLog via the FMDB/sqlite3 dependency. If you can find the underlying SQLite error in the logs that would be helpful.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cloudant/CDTDatastore/issues/453#issuecomment-470978514, or mute the thread https://github.com/notifications/unsubscribe-auth/AIVeVyJE2y-nVF3S8WHQcm4_vkSGznEPks5vUojFgaJpZM4bduQ4 .

ricellis commented 5 years ago

Unfortunately I don't think so - NSLog output goes to directly to the system/OS log. Cocoalumberjack was previously able to capture that for older iOS versions that used ASL, but since iOS 10 and the change to os_log I don't believe that it is possible any more.

It might be possible to send the CDTDatastore logs to the unified logging system by using: [DDLog addLogger:[DDOSLogger sharedInstance]]; but I think you'd need to swap for a newer version of Cocoalumberjack than CDT uses and I'm not sure if there are any breaking API changes involved in that.

The messages do appear in the console in XCode if you are able to reproduce them in dev/test of your application though.

ricellis commented 2 years ago

Closing as this library is now EOL and this issue won't be fixed here. The issue has been tagged EOL in case any forks want to import it.