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

Sync queue updates #8342

Merged

Conversation

rtibbles
Copy link
Member

@rtibbles rtibbles commented Aug 23, 2021

Summary

  • 1 place in the queue per user, don't duplicate
  • Filter by active or recently active transfer sessions to see if a sync is in progress
  • Make queue item expire time dynamic, so that items with a smaller keep_alive expire more quickly
  • Adds tests for the above
  • Resyncs regardless of whether the sync task failed or not
  • Makes queue places user/instance specific.

Reviewer guidance

Do the tests do what they purport?
Does the code do what it ought?


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@rtibbles rtibbles added the TODO: needs review Waiting for review label Aug 23, 2021
@rtibbles rtibbles added this to the 0.15.0 milestone Aug 23, 2021
Break up check_queue function to reduce cyclomatic complexity.
Copy link
Member

@jredrejo jredrejo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and in my tests it works perfectly. The user who was waiting longer is the first to sync everytime
turnos

@@ -118,7 +135,7 @@ def startpeerusersync(
job_data["resync_interval"] = resync_interval
JOB_ID = hashlib.md5("{}::{}".format(server, user).encode()).hexdigest()
job_data["job_id"] = JOB_ID
job = queue.enqueue(call_command, "sync", **job_data)
job = queue.enqueue(peer_sync, **job_data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks perfect

keep_alive=10,
)
queue = SyncQueue.objects.create(user_id=self.learner.id, keep_alive=10)
time.sleep(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have I ever said how much I hate adding sleep to the tests?... I know this is a bad windows behaviour so one more reason not-to-love that OS
btw, this discussion is related https://stackoverflow.com/questions/85451/pythons-time-clock-vs-time-time-accuracy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I am not a huge fan, but it seems like the only way :/

@rtibbles rtibbles merged commit 4309fdf into learningequality:release-v0.15.x Aug 24, 2021
@rtibbles rtibbles deleted the sync_queue_updates branch August 24, 2021 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants