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

Fix Re-ordering of Related Resource Ids #236

Conversation

mbarackman-coursera
Copy link
Contributor

  • After merging a recent fix that de-duplicated ids we found that related resource elementIds and elements arrays were being re-ordered in a non-deterministic way during every request. In particular our moduleIds were being re-ordered and the order has actual meaning.

  • It turns out that the previous de-duplication fix had introduced sets and hence this non-determinism. I’ve replaced the Set introduced in parseIds with a Seq and this has corrected the problem.

  • I tested using prod-preview and now the problem has gone away.

- After merging a recent fix that de-duplicated ids we found that related resource `elementIds` and `elements` arrays were being re-ordered in a non-deterministic way after every request.

- In particular our moduleIds were being re-ordered and the order has actual meaning. It turns out that the previous de-duplication fix had introduced sets and hence this non-determinism.

- I’ve replaced the Set introduced in parseIds with a Seq and this has corrected the problem.
Copy link
Contributor

@cliu587 cliu587 left a comment

Choose a reason for hiding this comment

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

Thanks!

case ("ids", ids) => ids
}
private[this] def parseIds(request: NaptimeRequest): Seq[JsValue] = {
request.arguments.toSeq.filter { case (key, _) => key == "ids" }.map(_._2)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a note that .toSeq is to respect order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure thing. thanks

@mbarackman-coursera mbarackman-coursera merged commit 245f704 into coursera:master Apr 3, 2018
@mbarackman-coursera mbarackman-coursera deleted the MPB-fix-reordering-bug branch April 3, 2018 02:07
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

Successfully merging this pull request may close these issues.

None yet

2 participants