How to prevent "ATOMIC_ERROR" with CloudKit? - atomic

The last few days I see that some users are generating a lot of errors that are labeled as "ATOMIC_ERROR" in the CloudKit dashboard Telemetry view. I have search a bit on this, but I see only some documentation related to CloudKit JS. I don't use that, I just use the standard CloudKit library within a multiplatform macOS/iOS/tvOS app.
To which CKError does ATOMIC_ERROR map? CKErrorPartialFailure
perhaps?
What's the universal way to replicate this error?
How to prevent this error?
BTW:
I'm aware of property isAtomic. I always set property isAtomic in batch updates to false, because I don't need data integrity between multiple records in one zone. Therefore I don't expect 'atomic' related errors.

Related

How to use sharing with CoreData/CloudKit synching

I have an app that works well synchronizing the local core data records with a private database. I would like to make the CloudKit database a shared database and then selectively share records with users. Is this even possible.
In other words, I'd like to continue having the Core Data/CloudKit sync working, but with the records that get synched limited to the user's share(s).
Does anyone have examples or a link to a discussion of this?
Apple solved this last year at WWDC21
Here is a link to the video
https://developers.apple.com/videos/play/wwdc2021/10015/
and some useful example code:
https://github.com/delawaremathguy/CoreDataCloudKitShare

postgresql concurrent transactions

I have a project that I'm working on that uses a background thread to insert data into the database from a different source. Now one of the problems that I have occasionally, once the user interacts with the database an error due to "could not serialize access due to concurrent update" is triggered.
Because my data source generates a lot of data my background thread is always busy keeping up and inserting the data and I've written the algorithm to basically "retry" whenever a row is locked, so I can live with the occasional error that occurs on the background thread.
The real problem is that my users basically interact with the database via a website that has ORM mapping in various layers and it seems that occasionally the user might be modifying the same record that is being worked on by the background thread.
Is there any recommendation of what I could do make my not be confronted with the serialization errors?
Presumably your users have been presented with some data from the database, and based on what they saw have decided to change something. If the data they looked at is obsolete, why would you expect that decision based on obsolete information to still stand? In general, they need to look at the more-current data and decide if they still want to make the change.
If those decisions are "easy" to make, then why do you have humans making them in the first place? And if they are hard to make, what choice is there but to have the people re-make them? There may be particular answers to this, but I don't see any general answers, and you haven't given us any particular details to work with.

CloudKit: multiple users writing to same record at same time

I am currently working on handling CloudKit errors for an app I've been developing. One major issue I need to handle is this: multiple users writing to the same record at the same time.
What is the best way to handle this issue with CloudKit (in Swift)? Do I need to add some sort of lock on the record so that only one user can edit at a time? Does CloudKit do this for me automatically? If so, should I re-try the operation after some interval of time? Do I need a queue to hold tasks that are waiting to be done on that record?
Any insight into how CloudKit intends for me to handle these sorts of issues would be much appreciated! Thanks!
You have to handle CKRecord Conflicts in a way that suits your application. One way to handle is Latest update wins. To make it working, you can have a field on CKRecord, say lastModified.
You can have the savePolicy for CKModifyRecordsOperation set to ifServerRecordUnchanged
When saving the record, Cloudkit throws you serverRecordChanged error.
With this error, you'll also have 3 versions of CKRecord.
1.) The prior version of the record you tried to save,
2.) The exact version of the record you tried to save,
3.) The version held by the server at the time you submitted the request.
By comparing lastModified field of the CKRecord, you can decide which CKRecord wins.

How to get the actual quota for CloudKit?

Im using Cloudkit and the private database to store some files to iCloud and sync between iOS und OSX.
Now I wanted to implement something, the user can see how much space is left in his iCloud without leaving the app and look in the preferences. But I cant't find any information how to get this data. The whole CloutKit Framework reference has no object or method that gives me this information.
Because the private database uses the normal iCloud quota of the user, I could work around by looking for this data over any other iCloud API.
Anybody has an hint for me or a way to get this infos?
There isn't currently a way to get the remaining quota for a user in the private database at this time, so your best option is to just try to upload the data you want and watch for a CKErrorQuotaExceeded error.

Access Record record - show lock status

I use a datasheet view of a query with aggregate sub queries attached as fields. Of course this is not editable and that is fine as its merely an overview listing of all the records along with some sum information from related tables. I have noticed that when a query is not editable the record selector lock information is not displayed. This made me wonder.
Is there is some event that can be captured to display in more or less real time when a record is locked or released by other users?
Alternatively is there any other way to display in my overview list or elsewhere what records are currently locked and if possible by what user?
Access 2010(x64)
For an updatable query, the locked status may be displayed on the left margin as you have noted. But that reflects record-locking by the query engine, not the same thing as whether a data result is updateable under normal circumstances.
For a read-only query, Access won't show a lock icon because in that context it isn't useful information (from most people's point of view).
You could use VBA to check the attribute of the query as a whole, and display a notification when the form is loaded. But that doesn't relate to the record-locking icon.
Is there is some event that can be captured to display in more or less real time when a record is locked or released by other users? -- I believe the simple answer is no.
Access 2007 saw the end of the JET Security model, so there is no way for you to manage user-level security in files created using 2007 or later.
The only alternative would be to use the Win API to register users by their NT ids, and to develop your own model which responded to activity. Clearly this would be no mean feat!
[Edit]
As for detecting record locks, it's possible you could implement this using an events handler class together with the ADO library:
http://msdn.microsoft.com/en-gb/library/windows/desktop/ms678373%28v=vs.85%29.aspx
If you don't mind getting your hands dirty with Class Modules (something some pundits never got to grips with), then you can find a lead-in here.