PFUbiquity error when using Core Data and iCloud - core-data

I am using iCloud to sync my Core Data store. This works fine. I just noticed that when I launch the app I get the following error message. Is this normal? Is there something I can do to prevent it?
Thanks
2014-12-06 10:06:37.337 -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](808): CoreData: Ubiquity: nobody~sim352B6DF3-0975-5C4B-B561-086A3032D6EA:ContentKeyName
Using local storage: 1
2014-12-06 10:06:37.382 __60-[PFUbiquitySetupAssistant canReadFromUbiquityRootLocation:]_block_invoke682(1476): CoreData: Ubiquity: Attempting to download Peers hit a serious error for peers to download Error Domain=BRCloudDocsErrorDomain Code=5 "The operation couldn’t be completed. (BRCloudDocsErrorDomain error 5 - No document at URL)" UserInfo=0x7ff77ac9b110 {NSDescription=No document at URL, NSFilePath=/Users/dev/Library/Developer/CoreSimulator/Devices/0AC7A779-9C6C-4A6C-91C5-D1973CE278D9/data/Library/Mobile Documents/iCloud~app~container/Data/.DS_Store, NSUnderlyingError=0x7ff77ac990d0 "The operation couldn’t be completed. No such file or directory"} with userInfo {
NSDescription = "No document at URL";
NSFilePath = "/Users/dev/Library/Developer/CoreSimulator/Devices/0AC7A779-9C6C-4A6C-91C5-D1973CE278D9/data/Library/Mobile Documents/iCloud~app~container/Data/.DS_Store";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\" UserInfo=0x7ff77ac9bee0 {NSDescription=No such file or directory}";
}
2014-12-06 10:06:37.409 -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](808): CoreData: Ubiquity: nobody~sim352B6DF3-0975-5C4B-B561-086A3032D6EA:ContentKeyName
Using local storage: 0

Based on my testing, here's what I believe is the problem.
When your local Core Data resources sync with iCloud, any rows deleted on another device are deleted. More rows can be deleted through the de-dupe process.
In memory you may be holding ManagedObjects which represent deleted rows directly, or may be related to those rows.
So, when you access the properties of those rows, the fault process expects to find Core Data rows, but it doesn't. The inconsistency causes the error.
My solution: Refresh all ManagedObject subclassed objects whenever you receive a NSPersistentStoreCoordinatorStoresDidChangeNotification or NSPersistentStoreDidImportUbiquitousContentChangesNotification
This worked for me. Hopefully, someone else can profit from this too.

Related

How can i do core data migration?

I have an old core data version with Allows external storage in Binary data. And i have created a new one where Allows external storage was unchecked. When i tried to launch my app i got an error:
Unresolved error
Error Domain=NSCocoaErrorDomain Code=134140 "The operation couldn’t be
completed. (Cocoa error 134140.)" UserInfo=0xbd5cd20 {reason=Can't
find or automatically infer mapping model for migration,
destinationModel=...
Then I have created a new file in my project - Model.xcmappingmodel. I have selected source data model and target data model.
After that i see
NSPersistentStoreCoordinator error: NSPersistentStoreCoordinator
_coordinator_you_never_successfully_opened_the_database_schema_mismatch
For future context ... writing to CoreData's external storage is broken as of iOS 12. My solution was based off Drew McCormack's comments on Twitter.
It's worth noting that only writing is broken, reading remains functional.
Create a new property eg «original property name»Internal with the same type but with Allows external storage box unchecked.
You now have two options:
Migrate everything on initial startup of the app - ie fetch all objects with a predicate like this «original property name»Internal == NULL && «original property name» != NULL and move the data across (I did this).
Migrate on the fly ie use the two properties in parallel but only write to «original property name»Internal (while niling «original property name»)
Worth noting one last time that your customer's data is safe until they update it. Tred carefully but you should be fine.

UserErrorSqlBulkCopyInvalidColumnLength - Azure SQL Database

I am configuring a Salesforce to Azure SQL Database data copy using Azure Data Factory. There appears to be an issue with the column length, but I am unable to identify which column is actually causing an issue.
How can I gain more insight into exactly what is causing my problem? or what column is really invalid?
{
"dataRead":18560714,
"dataWritten":0,
"rowsRead":15514,
"rowsCopied":0,
"copyDuration":34,
"throughput":533.109,
"errors":[
{
"Code":9123,
"Message":"ErrorCode=UserErrorSqlBulkCopyInvalidColumnLength,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=SQL Bulk Copy failed due to received an invalid column length from the bcp client.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Data.SqlClient.SqlException,Message=The service has encountered an error processing your request. Please try again. Error code 4815.\r\nA severe error occurred on the current command. The results, if any, should be discarded.,Source=.Net SqlClient Data Provider,SqlErrorNumber=40197,Class=20,ErrorCode=-2146232060,State=1,Errors=[{Class=20,Number=40197,State=1,Message=The service has encountered an error processing your request. Please try again. Error code 4815.,},{Class=20,Number=0,State=0,Message=A severe error occurred on the current command. The results, if any, should be discarded.,},],'",
"EventType":0,
"Category":5,
"Data":{
},
"MsgId":null,
"ExceptionType":null,
"Source":null,
"StackTrace":null,
"InnerEventInfos":[
]
}
],
"effectiveIntegrationRuntime":"DefaultIntegrationRuntime (East US 2)",
"usedCloudDataMovementUnits":4,
"usedParallelCopies":1,
"executionDetails":[
{
"source":{
"type":"Salesforce"
},
"sink":{
"type":"AzureSqlDatabase"
},
"status":"Failed",
"start":"2018-03-01T18:07:37.5732769Z",
"duration":34,
"usedCloudDataMovementUnits":4,
"usedParallelCopies":1,
"detailedDurations":{
"queuingDuration":5,
"timeToFirstByte":24,
"transferDuration":4
}
}
]
}
"Message":"ErrorCode=UserErrorSqlBulkCopyInvalidColumnLength,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=SQL
Bulk Copy failed due to received an invalid column length from the bcp
client.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Data.SqlClient.SqlException,Message=The
service has encountered an error processing your request. Please try
again. Error code 4815.\r\nA severe error occurred on the current
command. The results, if any, should be
discarded.,Source=.Net SqlClient Data
Provider,SqlErrorNumber=40197,Class=20,ErrorCode=-2146232060,State=1,Errors=[{Class=20,Number=40197,State=1,Message=The service has encountered an error processing your request. Please try
again. Error code 4815.,},{Class=20,Number=0,State=0,Message=A severe
error occurred on the current command. The results, if any,
should be discarded.
I have seen that error when trying copy a string from the source to the destination but the column receiving the string on the destination is shorter than the source.
My suggestion is to make sure you selected data types big enough on the destination so they can receive the data from the source. Make sure also the sink has the columns shown in the preview.
To identify which column may be involved, exclude big columns one by one from the source.

Error Domain=BRCloudDocsErrorDomain Code=5 "No document at URL" - iCloud / Core Data

I'm currently struggling with iCloud integration on Core Data. As far as I can tell all the data is syncing ok but I'm constantly being given errors like the below and wondered if there was something wrong with my setup?
If it helps, this is the store URL prior to addPersistentStoreWithType:
--- Store URL Before: file:///var/mobile/Containers/Data/Application/86068CC8-9AF6-45A0-8157-407A52743CC1/Documents/Stores/AppNameicloud.sqlite ---
This is the store URL afterwards:
--- Store URL After: Optional(file:///var/mobile/Containers/Data/Application/86068CC8-9AF6-45A0-8157-407A52743CC1/Documents/Stores/CoreDataUbiquitySupport/mobile~69EC9D33-32CE-4747-9C92-FE89F2369F93/AppNameStore999/E9B4AB9A-B977-4E96-AD1E-5345083FED0F/store/AppNameicloud.sqlite))
Here is the error which appears:
2016-05-30 18:55:30.686 AppName[1000:311564] __45-[PFUbiquityFilePresenter processPendingURLs]_block_invoke(447): CoreData: Ubiquity: Librarian returned a serious error for starting downloads Error Domain=BRCloudDocsErrorDomain Code=5 "No document at URL" UserInfo={NSDescription=No document at URL, NSFilePath=/var/mobile/Library/Mobile Documents/iCloud~com~yourcompany~AppName/AppNameURL999/mobile~69EC9D33-32CE-4747-9C92-FE89F2369F93/AppNameStore999/27MY6G4iIrmUdOAL1QfH7d4IgISU63AZIEyfyZjrCL8=/35D54528-440F-4F48-981E-951A0E8A4C10.1.cdt, NSUnderlyingError=0x1410fb020 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={NSDescription=No such file or directory}}} with userInfo {
NSDescription = "No document at URL";
NSFilePath = "/var/mobile/Library/Mobile Documents/iCloud~com~yourcompany~AppName/AppNameURL999/mobile~69EC9D33-32CE-4747-9C92-FE89F2369F93/AppNameStore999/27MY6G4iIrmUdOAL1QfH7d4IgISU63AZIEyfyZjrCL8=/35D54528-440F-4F48-981E-951A0E8A4C10.1.cdt";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"No such file or directory\" UserInfo={NSDescription=No such file or directory}";
} for these urls: {(
file:///var/mobile/Library/Mobile%20Documents/iCloud~com~yourcompany~AppName/AppNameURL999/mobile~69EC9D33-32CE-4747-9C92-FE89F2369F93/AppNameStore999/27MY6G4iIrmUdOAL1QfH7d4IgISU63AZIEyfyZjrCL8=/7F0AFB84-FE8D-4476-99E7-D3F6620625E2.1.cdt
)}
I did notice the following in the icloud programming guide for core data:
Note: The store’s final URL may be different from the URL you passed in. If you need a reference to the persistent store, use the URL generated by the coordinator rather than the one you created.
Could this have something to do with the "No such file or directory" Error and should I be checking each time the app loads if there is an iCloud database, then add that instead of passing the Applications Directory version?
As I said, it appears to be working but I'm worried about submitting an update as these Errors look quite bad and do not wish users to lose data.
Thanks
========
After a period of time it definitely gets out of sync and some data stops syncing. I did notice a slightly different Error:
2016-05-30 19:53:44.613 AppNameuntil[4570:983927] +PFUbiquityLocation createUbiquityLocationForPath:withUbiquityRootLocation:: CoreData: Ubiquity: Unable to continue parse components of URL: /Users/Richard/Library/Developer/CoreSimulator/Devices/B6E71CE1-FE9A-47E2-83AE-6440695E5062/data/Library/Mobile Documents/iCloud~com~yourcompany~AppNameUntil/AppNameUntilURL999/mobile~55EC7AD8-2DD1-4C57-8977-B3A6101446EE/AppNameUntilStore999/27MY6G4iIrmUdOAL1QfH7d4IgISU63AZIEyfyZjrCL8=/44843227-1C63-44CD-855D-B3BE5B5C0BA7
Confused by: 44843227-1C63-44CD-855D-B3BE5B5C0BA7

Azure SQL Data Warehouse: No catalog entry found for partition ID <id> in database <id>. The metadata is inconsistent. Run DBCC CHECKDB

I am working on moving stored procedures from an on-prem SQL Server database to an Azure SQL Data Warehouse (ASDW). Throughout the process I have had to work around a few missing features - time consuming but not impossible. One thing I have had to do is replace CTE's followed by MERGE statements with temp tables followed by UPDATE/INSERT/DELETE statements (since CTE's cannot be followed by these statements). At the beginning of each SP I check for the temp tables and delete them if they exist.
Today, I created another stored procedure in the ASDW without any temp tables (no updates/inserts/deletes so I left the CTE's in there), it "compiled", and I was able to run it without issue (returned an empty result set, as there is no data yet). I created another SP after this, and when I went to execute it, I got the following error:
...No catalog entry found for partition ID (id) in database 26. The metadata is inconsistent. Run DBCC CHECKDB to check for a metadata corruption...
I then went back to the first SP that I mentioned, and it gave me the same error, even though it had previously run without flaw.
I tried running DBCC CHECKDB as instructed but alas, it is not supported/doesn't work.
I dug around a lot, and what I ended up doing was scaling my database from 100DWU's to 500DWU's. I am at 0.16% of my database storage size limit, and there is barely any data anywhere (total DB size is <300MB).
Is there an explanation for this? If not, I can't in good conscience use this platform in a production environment.
Full error:
Msg 110802, Level 16, State 1, Line 1
110802;An internal DMS error occurred that caused this operation to fail.
Details: Exception: Microsoft.SqlServer.DataWarehouse.DataMovement.Workers.DmsSqlNativeException,
Message: SqlNativeBufferReader.Run, error in OdbcExecuteQuery: SqlState:
42000, NativeError: 608, 'Error calling: SQLExecDirect(this->GetHstmt(), (SQLWCHAR *)statementText, SQL_NTS), SQL return code: -1 | SQL Error Info:
SrvrMsgState: 1, SrvrSeverity: 16, Error <1>: ErrorMsg: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]No catalog entry found for partition ID
72057594047758336 in database 36. The metadata is inconsistent. Run DBCC
CHECKDB to check for a metadata corruption. | Error calling: pReadConn-
>ExecuteQuery(statementText, bufferFormat) | state: FFFF, number: 134148,
active connections: 100', Connection String: Driver={pdwodbc};APP=TypeC01-
DmsNativeReader:DB196\mpdwsvc (2504)- ODBC;Trusted_Connection=yes;AutoTranslate=no;Server=\\.\pipe\DB.196-
bb5f9dd884cf\sql\query
I'm sorry to hear about your experience with Azure SQL Data Warehouse. I believe this is a defect related to BIT data type handling for NOT NULL columns. Can you confirm that you have a BIT NOT NULL column (e.g., CREATE TABLE t1 (IsTrue BIT NOT NULL);)?
If so, a fix has been coded and is in testing for release. To mitigate this now, you can either switch to a TINY INT or remove the NOT NULL setting for the column.

Core data/iCloud seeding with local xml file throwing errors in iOS8

Hopefully this is something simple but I haven't been able to track down a fix yet. I have an application that I'm trying to implement both iCloud and Core Data with. I'd like it to run on iOS7 and iOS8.
The application is a checklist/tableview application for collectibles.
Essentially, the application has an pre-seeded xml file with about 50,000 in it. The sqlite/core data is initially configured to have just 1 item. Users can, from a table view, select groups to add to the core data store (so that not all 50,000 items are included). When the user selects a group that has 1-50 items, it parses the xml for those items and writes them into the core data store. When a user selects a group that has a larger amount of files, it parses and adds them, but then also throws some random "no document at url" errors during the parsing process. The application doesn't crash, and all items seem to be added, but the application stops synching with iCloud. The exact error is:
__45-[PFUbiquityFilePresenter processPendingURLs]_block_invoke(439): CoreData: Ubiquity:
Librarian returned a serious error for starting downloads Error Domain=BRCloudDocsErrorDomain Code=5
"The operation couldn’t be completed. (BRCloudDocsErrorDomain error 5 - No document at URL)"
UserInfo=0x7fd7f54abea0 {NSDescription=No document at URL,
NSFilePath=/Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848- 0D52D833E28A/data/Library/Mobile Documents/iCloud~com~xxxxx~xxxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/C45FA553-6CA0-4C26-845B-B478EF7EAD60.1.cdt,
NSUnderlyingError=0x7fd7f54aa200 "The operation couldn’t be completed. No such file or directory"}
with userInfo {
NSDescription = "No document at URL";
NSFilePath = "/Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile Documents/iCloud~com~xxxxxxx~xxxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/C45FA553-6CA0-4C26-845B-B478EF7EAD60.1.cdt";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed.
No such file or directory\" UserInfo=0x7fd7f5433240 {NSDescription=No such file or directory}";
} for these urls: (
"file:///Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile%20Documents/iCloud~com~xxxxxxx~xxxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/C45FA553-6CA0-4C26-845B-B478EF7EAD60.1.cdt"
)
Then I will get a "move" error as well (sometimes after the parse is complete):
[PFUbiquityTransactionLog moveFileToPermanentLocationWithError:](761): CoreData: Ubiquity:
CoreData: Ubiquity: Error writing export log to file: file:///Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile%20Documents/iCloud~com~xxxxxxx~xxxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/ABE37211-02B7-4F20-B631-B5D91B23E9BE.1.cdt
error: Error Domain=NSCocoaErrorDomain Code=516 "The operation couldn’t be completed. (Cocoa error 516.)"
UserInfo=0x7fd7f49cdfd0 {NSSourceFilePathErrorKey=/Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile Documents/iCloud~com~xxxxxx~xxxxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/tempLogs.nosync/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/ABE37211-02B7-4F20-B631-B5D91B23E9BE.1.cdt,
NSUserStringVariant=(
Move
), NSDestinationFilePath=/Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile Documents/iCloud~com~xxxxxx~xxxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/ABE37211-02B7-4F20-B631-B5D91B23E9BE.1.cdt,
NSFilePath=/Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile Documents/iCloud~com~xxxxxx~xxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/tempLogs.nosync/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/ABE37211-02B7-4F20-B631-B5D91B23E9BE.1.cdt,
NSUnderlyingError=0x7fd7f497f430 "The operation couldn’t be completed. File exists"}
userInfo: {
NSDestinationFilePath = "/Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile Documents/iCloud~com~xxxxxx~xxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/ABE37211-02B7-4F20-B631-B5D91B23E9BE.1.cdt";
NSFilePath = "/Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile Documents/iCloud~com~xxxxxxx~xxxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/tempLogs.nosync/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/ABE37211-02B7-4F20-B631-B5D91B23E9BE.1.cdt";
NSSourceFilePathErrorKey = "/Users/zacharyfisher/Library/Developer/CoreSimulator/Devices/4B70FCFC-4704-4C83-B848-0D52D833E28A/data/Library/Mobile Documents/iCloud~com~xxxxxxx~xxxxxxx/CoreData/iCloud/nobody~sim43DA22C4-427B-5FCD-9B61-90CE79638F6B/tempLogs.nosync/iCloud/PZbSJk1f2RNB6ucDj0Y6VqL1KgXYAxi4LcApXONjvnQ=/ABE37211-02B7-4F20-B631-B5D91B23E9BE.1.cdt";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=17 \"The operation couldn\U2019t be completed. File exists\"";
NSUserStringVariant = (
Move
);
}
Any thoughts on how to fix this? Am I trying to make too many changes at once and that is crashing the core data/icloud synching? Any thoughts or pointers would be appreciated.
Zack
Zack, this isn't an answer (I don't have the rep to comment), but it might help you get on the right track. I'm implementing iCloud core data and am running into what looks like the same problem with iOS 8... same "No document at URL" error (no move error for me), and same breakdown in data sync. Two observations:
When I am running my app on two devices, core data sync initially works very well... like for a few minutes and a few updates. Then I get the "no document at URL" error.
My .sqlite database is very small and the updates I'm trying to make are modest (e.g. adding a single new entity), so I don't think file sizes or update complexity are factors.
On the device where these errors are logging, the store stops importing changes from iCloud. But changes I make on that device do continue to persist to the other device. So the effect is like a one-way breakdown.
Hope this helps. Would appreciate posts on any progress you make. I've been wrestling with this for several weeks and am close to giving up and shipping the app (which is universal) without iCloud data sync.

Resources