Skip to content
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

zephyrRemoteStoreDictionary[ZephyrSyncKey] reports incorrect time #29

Closed
Sam-Spencer opened this issue Apr 15, 2018 · 8 comments
Closed

Comments

@Sam-Spencer
Copy link

Sam-Spencer commented Apr 15, 2018

Initially, when I reported this issue, I thought it was due to a synchronization timing / data race issue, but I have since found otherwise.

It appears that the date stored in zephyrRemoteStoreDictionary[ZephyrSyncKey] often supplies the incorrect time, thus causing data lost for the local store. Although I have yet to pinpoint the cause of the issue, this key fairly consistently (2 out of every 3 calls) reports a time that is ahead of the local time. Unfortunately, this means that when updating a default in the local store that is newer than the default stored remotely, the older remote value trumps the new local value.

I will continue looking into the issue and see if I can find out any additional information. Hopefully we can get this fixed!

Thank you for this project - saved me a good chunk of time, and it's beautifully written! 🍻

@Sam-Spencer Sam-Spencer changed the title Reading defaults immediately after sync results in lost data zephyrRemoteStoreDictionary[ZephyrSyncKey] reports incorrect time Apr 15, 2018
@Sam-Spencer
Copy link
Author

[bump] After further testing, I've edited the issue report with the actual underlying problem.

@ArtSabintsev
Copy link
Owner

Hey.

Thanks for the bug report!

I'm wondering how large the discrepancy is. Would you be able to provide the sync times in two scenarios:

  • When a default is sent to the cloud
  • When that default is retrieved from the cloud

This is where the time is being set to values being set to the cloud - maybe it needs to be more stringent and formatted?
https://github.com/ArtSabintsev/Zephyr/blob/master/Sources/Zephyr.swift#L287

@ArtSabintsev
Copy link
Owner

I'm just following up on this issue.

I have a 5 day rule - if an issue stays stale for 5 days, I close it for my own peace of mind.

Thanks!

@ArtSabintsev
Copy link
Owner

Closing this issue due to lack of activity.

@Sam-Spencer
Copy link
Author

Below is the time difference when a local change is made and is being sent up to iCloud:

screen shot 2018-05-30 at 12 34 10 pm

Despite the local change actually happening more recently, the date of the remote change is set ahead.

Further testing with some print statements to the console shows that this difference can sometimes be as little as a second or two:

DATES
CURRENT: 2018-05-30 16:39:48 +0000
LOCAL: 2018-05-30 16:39:15 +0000
REMOTE: 2018-05-30 16:39:19 +0000

@Sam-Spencer
Copy link
Author

This seems like a difficult bug to track down... I thought maybe it had something to do with making changes rapidly and then needing to wait for those changes to get synced to iCloud. However, this doesn't seem to be the case. It happens fairly reliably (regardless of time waited) for every few updates sent to the cloud. The remote date is very elusive... any help would be appreciated.

@ArtSabintsev ArtSabintsev reopened this May 30, 2018
@ArtSabintsev
Copy link
Owner

Hey @Sam-Spencer, at this point, I'll need to see a sample project so that I can potentially track this issue down. I only maintain Zephyr at this point as the project this was built for is no longer being developed.

@ArtSabintsev
Copy link
Owner

The date is set here: https://github.com/ArtSabintsev/Zephyr/blob/master/Sources/Zephyr.swift#L285 - I'm not sure what the system is doing to have you lose precision like that. Maybe you're calling syncToCloud multiple times and very quickly and just don't realize it?

I'm going to close the issue because I can't seem to reproduce it on my end nor can I see anything in the code that can be pointed to as the culprit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants