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

RSDK-9588 - Always run updateWeakDependent within a lock #4645

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cheukt
Copy link
Member

@cheukt cheukt commented Dec 18, 2024

generally want to make sure that we're not trying to reconfigure the same thing at the same time across different go routines. There are 4 calls to updateWeakDependents - New, Reconfigure, completeConfig loop, and removeOrphanedResources. Since there wasn't a lock before, they have a chance of calling updateWeakDependents all at the same time.

Using the resourceGraphLock because updateWeakDependents in the completeConfig loop already takes the resourceGraphLock

@cheukt cheukt marked this pull request as ready for review December 18, 2024 22:37
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Dec 18, 2024
defer r.manager.resourceGraphLock.Unlock()
r.updateWeakDependents(ctx)
}

func (r *localRobot) updateWeakDependents(ctx context.Context) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not lock and defer unlock of resourceGraphLock at the top of this method instead of introducing the InLock method? Are you trying not to lock when calling from completeConfig in the resource manager (call updateWeakDependents without a lock? If so, why?

Copy link
Member Author

Choose a reason for hiding this comment

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

completeConfig already holds a resourceGraphLock so didn't think we should grab it again

Copy link
Member

Choose a reason for hiding this comment

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

Cool; that's sort of what I assumed. I don't have a super strong opinion, but I would've thought that the completeConfig call to weak dependents would be the one that's "abnormal" in terms of method name: something like updateWeakDependentsWithoutLock, while the other call sites are just updateWeakDependents and take the lock.

But also, I'm more broadly concerned with just adding this locking in the first place, so see my other comment.

@benjirewis
Copy link
Member

This was brought up offline briefly, but why are we adding extra locking here? It sounds like we haven't seen an issue wrt multiple updateWeakDependents racing, and I would go so far as to say that adding the locking you have here makes us at least susceptible to a new kind of deadlock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants