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 partial caching ignore repeated items issue #35145

Merged
merged 1 commit into from Apr 4, 2019

Conversation

st0012
Copy link
Contributor

@st0012 st0012 commented Feb 3, 2019

Summary

This is for #35114
Partial caching doesn't return the right collection when some of the items are repeated.

Let's say we have this template:

<%= cached_set.first %> | <%= cached_set.second %> | <%= cached_set.third %> | <%= cached_set.fourth %> | <%= cached_set.fifth %>

And a cached_set collection:

[1,2,3,4,5],
[1,2,3,4,4],
[1,2,3,4,5],
[1,2,3,4,4],
[1,2,3,4,6]

On current master, the rendered result will be

      "1 | 2 | 3 | 4 | 5",
      "1 | 2 | 3 | 4 | 4",
      "1 | 2 | 3 | 4 | 6"

The duplicated items are ignored.

This is because we only use hash to maintain the result. So when the key are the same, the result would be skipped.

@rails-bot rails-bot bot added the actionview label Feb 3, 2019
@st0012 st0012 changed the title Fix 35114 Fix partial caching ignore repeated items issue Feb 3, 2019
@st0012 st0012 force-pushed the fix-35114 branch 2 times, most recently from 878a36b to 0ea0bc6 Compare February 25, 2019 08:14
@st0012
Copy link
Contributor Author

st0012 commented Apr 1, 2019

@amatsuda are you willing to give this a quick scan if you have time? I'd really appreciate it 🙇

@@ -56,8 +60,11 @@ def collection_by_cache_keys(view, template)

digest_path = view.digest_path_from_template(template)

@ordered_keys = []
Copy link
Member

Choose a reason for hiding this comment

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

Instead of building this instance variable here and using in other methods we should return it and pass around.

@st0012
Copy link
Contributor Author

st0012 commented Apr 3, 2019

@rafaelfranca updated

Copy link
Member

@rafaelfranca rafaelfranca left a comment

Choose a reason for hiding this comment

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

Can you squash your commits?

This is because we only use hash to maintain the result. So when the key
are the same, the result would be skipped. The solution is to maintain
an array for tracking every item's position to restructure the result.
@st0012
Copy link
Contributor Author

st0012 commented Apr 4, 2019

@rafaelfranca done

@rafaelfranca rafaelfranca merged commit eda2d7d into rails:master Apr 4, 2019
@st0012 st0012 deleted the fix-35114 branch April 5, 2019 07:27
krauselukas added a commit to krauselukas/open-build-service that referenced this pull request Apr 15, 2020
In certain cases, the md5 and mtime value of a file is the same
for multiple files. Only the file name differs in those cases.
This needs to be considered, in order to have uniq data in the
cache.

In the past this lead to not show certain files in the
webui due to this rails/rails#35145
Since this got fixed, it now does the opposite (showing duplicated entries),
which is more obvious.

Since osc shows the correct files, and missing files are less
obvious than duplicates, this probably took a while to be reported
as an issue.

Fixes openSUSE#9352

Co-authored-by: David Kang <dkang@suse.com>
Co-authored-by: Eduardo Navarro <enavarro@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants