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 director list membership and temperature events #3130

Merged
merged 4 commits into from Nov 18, 2019

Conversation

nigoroll
Copy link
Member

this PR fixes #3094

We add missing locking for operations on the director list to ensure consistency with concurrent dynamic director additions and deletions.
We remove the temperature lock which prevented director deletions during COLD events and ensure that only backends on the director list receive events.

Please note that there is no explicit vtc, the test case has been added to vmod_debug and runs with every invocation of that vmod.

Please consider the individual commit messages for additional detail on the reasoning.

@dridi
Copy link
Member

dridi commented Nov 14, 2019

I'm not sure why we need 22e44fe looking at everything else, wherever you use the temperature on its own it comes from a VCL.

Otherwise, I'm happy to see the temperature rwlock go away and overall this looks good to me. I will look closer.

@dridi
Copy link
Member

dridi commented Nov 14, 2019

I think this is generally a good opportunity to get rid of the VCL_(COLD|WARM) macros too:

  • turn VCL_TEMP_* into structs
  • give them .cold and .warm fields
  • s/VCL_COLD(x)/(x)->cold/
  • s/VCL_WARN(x)/(x)->warm/

Copy link
Member

@dridi dridi left a comment

Choose a reason for hiding this comment

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

See previous comments.

@nigoroll
Copy link
Member Author

@dridi with all due respect, I think your suggestion is overkill. Accessing a field in a struct is by no means more efficient than two pointer comparisons (to compile time values), the suggestion does not contribute to the fix and I do not see how else it would be useful.
If you really think this would be needed, can we discuss it in a separate PR?

@nigoroll
Copy link
Member Author

I'm not sure why we need 22e44fe looking at everything else, wherever you use the temperature on its own it comes from a VCL.

this is used here: the temperature is saved inside the lock for consistency, then checked outside

if (!VCL_WARM(temp) && temp != VCL_TEMP_INIT)

@dridi dridi self-requested a review November 14, 2019 12:23
Copy link
Member

@dridi dridi left a comment

Choose a reason for hiding this comment

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

@dridi with all due respect, I think your suggestion is overkill.

I discussed it a long time ago and @bsdphk wants to move away from const char * compile-time constants for better type safety. It happened in other parts of the code base, but never here.

Accessing a field in a struct is by no means more efficient than two pointer comparisons (to compile time values), the suggestion does not contribute to the fix and I do not see how else it would be useful.

As explained above, this is not about efficiency, on this account I agree with you.

If you really think this would be needed, can we discuss it in a separate PR?

Like I said, now is a good opportunity to make this change since VCL temperature gets some scrutiny. I think this can be pushed directly to master once this is merged, I will do it.

@nigoroll
Copy link
Member Author

@dridi thank you for the explanation. The type safety argument makes sense.

we are going to need to check a temperature on its own
we ensure that only backends on the director_list receive events.
Because events happen in the cli thread, we do not need another level of
serialization.

There is no explicit vtc, the test case has been added to vmod_debug and
runs with every invocation of that vmod.

Fixes varnishcache#3094
@nigoroll nigoroll merged commit 6152985 into varnishcache:master Nov 18, 2019
nigoroll added a commit that referenced this pull request Nov 18, 2019
@nigoroll nigoroll deleted the fix_director_temp_lock branch November 18, 2019 15:34
fwsGonzo pushed a commit to fwsGonzo/varnish-cache that referenced this pull request Mar 27, 2020
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.

panic: VRT_DelDirector from VCL Event would deadlock / director locking wrong?
3 participants