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

Identify how sync can be made singleton #1150

Closed
mahalakshme opened this issue Oct 20, 2023 · 3 comments
Closed

Identify how sync can be made singleton #1150

mahalakshme opened this issue Oct 20, 2023 · 3 comments
Assignees

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Oct 20, 2023

As a user I want only one sync to be triggered in my app at a time, so that the app works in the designed way.

Currently we have disabled auto sync when manual sync is in progress. But manual sync can happen when auto sync is in progress as mentioned here and another manual sync can be triggered when a manual sync is in progress as mentioned in the steps to reproduce here. This results in duplicate of data, unexpected behavior and added server load.

Acceptance criteria:

  • Come up with a strategy to make the sync singleton by using lockfile or state variable or by any other way.
  • This strategy should be such that it should work, even when the process that has acquired the lock gets killed for some reason.
@mahalakshme mahalakshme converted this from a draft issue Oct 20, 2023
@mahalakshme mahalakshme moved this from In Analysis to In Analysis Review in Avni Product Oct 20, 2023
@mahalakshme mahalakshme moved this from In Analysis Review to Ready in Avni Product Oct 20, 2023
@1t5j0y 1t5j0y moved this from Ready to In Progress in Avni Product Oct 20, 2023
@1t5j0y 1t5j0y self-assigned this Oct 20, 2023
@1t5j0y
Copy link
Contributor

1t5j0y commented Oct 24, 2023

Parallel syncs analysis:

  1. Cannot start a second manual sync in parallel. If the app is in memory while a manual sync is in progress, the manual sync continues. On restoring the app, another manual sync cannot be started because the progress bar is shown. If the app is removed from working memory during manual sync, the sync stops. On restoring the app and starting manual sync, a fresh sync starts.
  2. Cannot initiate a second automatic sync when an automatic or manual sync is in progress. The existing strategy to schedule a dummy sync with the same job name has the desired effect of preventing a duplicate automatic sync from triggering. However, this has a side effect of always triggering an upload only sync immediately after a manual sync has completed due to us scheduling the automatic sync job again at the end of of manual sync. (which pushes nothing since a manual sync has just completed and the user has been prevented from performing any action on the app during the sync due to the display of the progress bar).
  3. Can initiate a manual sync while an automatic sync is in progress as detailed in Duplicate images #1132 .

Hence the only scenario left to be handled is 3. There is existing state SyncActions.syncing to indicate whether a sync is currently in progress. This is currently not being set when the automatic sync is going on. We can change logic to set this to true even for automatic sync and use it to update the sync button UI and disable it (without interrupting the user) to indicate that an automatic sync is in progress which will take care of this scenario. Some additional handling to not show the progress bar for this scenario will also need to be handled.

@mahalakshme
Copy link
Contributor Author

This this state, SyncActions.syncing will get reset when the app gets killed and we start it again right? just confirming.

@1t5j0y
Copy link
Contributor

1t5j0y commented Oct 24, 2023

correct.

@1t5j0y 1t5j0y moved this from In Progress to Analysis Complete in Avni Product Oct 24, 2023
@mahalakshme mahalakshme moved this from Analysis Complete to Done in Avni Product Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants