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

can't add a new key into hash during iteration #436

Closed
gingerlime opened this issue Jan 6, 2022 · 11 comments
Closed

can't add a new key into hash during iteration #436

gingerlime opened this issue Jan 6, 2022 · 11 comments

Comments

@gingerlime
Copy link

gingerlime commented Jan 6, 2022

Describe the bug
We saw this error (albeit only once) after upgrading to the latest coverband

To Reproduce
Not sure unfortunately...

Here's part of the stack trace


1
File "/usr/lib/ruby/3.0.0/set.rb" line 355 in add
2
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/coverband-5.2.0/lib/coverband/collectors/view_tracker.rb" line 53 in track_views
3
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/coverband-5.2.0/lib/coverband/utils/railtie.rb" line 41 in block (2 levels) in <class:Railtie>
4
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.4/lib/active_support/notifications/fanout.rb" line 186 in finish
5
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.4/lib/active_support/notifications/fanout.rb" line 63 in block in finish
6
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.4/lib/active_support/notifications/fanout.rb" line 63 in each
7
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.4/lib/active_support/notifications/fanout.rb" line 63 in finish
8
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.4/lib/active_support/notifications/instrumenter.rb" line 45 in finish_with_state
9
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.4/lib/active_support/notifications/instrumenter.rb" line 30 in instrument
10
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.4/lib/active_support/notifications.rb" line 203 in instrument
11
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/actionview-6.1.4.4/lib/action_view/renderer/partial_renderer.rb" line 280 in render_partial_template
12
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/actionview-6.1.4.4/lib/action_view/renderer/partial_renderer.rb" line 271 in render
13
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/actionview-6.1.4.4/lib/action_view/renderer/renderer.rb" line 81 in render_partial_to_object
14
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/actionview-6.1.4.4/lib/action_view/renderer/renderer.rb" line 53 in render_partial
15
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/actionview-6.1.4.4/lib/action_view/helpers/rendering_helper.rb" line 45 in render
16
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/haml-5.2.2/lib/haml/helpers/action_view_mods.rb" line 13 in block in render
17
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/haml-5.2.2/lib/haml/helpers.rb" line 93 in non_haml
18
File "/var/local/kenhub/kenhub.d/73/vendor/bundle/ruby/3.0.0/gems/haml-5.2.2/lib/haml/helpers/action_view_mods.rb" line 13 in render
19
File "/var/local/kenhub/kenhub.d/73/app/views/layouts/_base_header.haml", line 3 in block in _app_views_layouts__base_header_haml__4267542119396688185_99240

Expected behavior
No error? :)

Screenshots
see above

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows 10
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] 96

Additional context
It seemed to have happened shortly after deploying the latest version of coverband, but only to one user, and only once...

@danmayer
Copy link
Owner

danmayer commented Jan 7, 2022

hmm thanks @gingerlime I haven't been able to reproduce yet... I am upgrading a bunch of apps in the next week so perhaps I will see it as the deployment expands. If you see it again let me know... Might need to dig a bit more into that bit in the view tracker

@gingerlime
Copy link
Author

Thanks @danmayer. It seemed to have happened in both our staging and live environment, but only once in each environment after we upgraded... So I'm not entirely sure how to reproduce it either... I can try to play with it a bit and maybe clear the data, but it might be more tricky and time-consuming if I have to downgrade/upgrade obviously... Hope you can spot something as well.

@danmayer
Copy link
Owner

danmayer commented Jan 8, 2022

OK, interesting the once per environment gives me at least a clue about it being a one time upgrade issue.

@gingerlime
Copy link
Author

yep seems very likely. maybe not worth worrying about then? but just thought better safe than sorry so I reported it :)

@gingerlime
Copy link
Author

Hi @danmayer. We just got this error again on deploy. I'm not entirely sure what changed in our code to have triggered it, but it now looks like it's not a completely one-off thing...

@danmayer
Copy link
Owner

OK, I will take a closer look and see if I can reproduce it tonight. Can you share your Rails, Ruby, and Redis version?

@gingerlime
Copy link
Author

Thank you! We're using Rails 6.1, Ruby 3.0.2 and Redis 5.x (redis-rb is 4.5.1)

@danmayer
Copy link
Owner

OK, pushed up what I think should be a fix. It still hasn't reproduced on any of our apps, but I am pretty sure I see where the thread race condition in our view tracker could occur.

Try out this RC release and let me know if it solves the issue 5.2.1.rc.1

@gingerlime
Copy link
Author

can’t repro reliably either but will give it a try :) thank you!

@gingerlime
Copy link
Author

We still see some errors on deploy on production (not every deploy, but some), and with the rc on staging, we don't see those errors... So it looks like a safe bet 👍

@danmayer
Copy link
Owner

OK great, I released 5.2.1 to rubygems. If you see more let me know

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