-
Notifications
You must be signed in to change notification settings - Fork 77
Fix user modification timestamp. #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| line: UInt = #line, | ||
| column: UInt = #column | ||
| ) async throws { | ||
| ) async throws -> SendRecordsCallback { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need this bit of infrastructure in the mocks to wiggle in between the moment a batch is sent out to iCloud and the moment the sentRecordZoneChanges delegate method is called.
| self.userModificationTime = #sql(""" | ||
| max(\(self.userModificationTime), \(lastKnownServerRecord.userModificationTime)) | ||
| """) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix.
| title🗓️: 2, | ||
| 🗓️: 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can write a failing test that shows data not properly syncing (we need to better support multiple sync engines in a test), but this at least shows the edit was made at the right time. Without the changes in this PR this timestamp was 1.
|
|
||
| extension CKRecord { | ||
| @TaskLocal static var printTimestamps = false | ||
| @TaskLocal static var printRecordChangeTag = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted a way to get visibility into record change tags.
|
Hi @mbrandonw, reading the description mentioning the step of preparing changes for upload and seeing the fix in
If so, I’d like to point out that this very spot exhibits different behavior between production and tests. I reported it in #356. The short version is that in tests, the record is always written, as the mock database doesn’t set CloudKit’s internal However, even when aligning the behavior between test and production environments, I wonder why we would ever want to save an in-flight record as the last-known server record before it’s confirmed by the server. I point it out in step 4 of scenario 2.1 in my document on the current behavior. It breaks the model for a potential three-way merge conflict resolution, as it would prevent using the last-known server record as the ancestor. |
No, the problematic call stack actually originates from
Yeah, it does seem like we should better emulate
Yeah, to be honest I don't remember why we do that. And removing that call to - isCompleted🗓️: 30,
+ isCompleted🗓️: 60,And I'm trying to think which is correct. The |
If a write is made to the database while a batch of records is being prepared and sent to iCloud, it is possible for us to accidentally cache an old timestamp on the the records. That could prevent other devices from updating their local data with fresh server data.