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

[x/sync] Update target locking #1762

Closed
wants to merge 3 commits into from
Closed

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Jul 25, 2023

Why this should be merged

Might resolve: #1760

How this works

We ensure that the sync target cannot be updated while we are determining whether to re-add completed workItems to the queue or mark as processed.

How this was tested

HyperSDK: ava-labs/hypersdk#278

@patrick-ogrady patrick-ogrady marked this pull request as draft July 25, 2023 22:06
@patrick-ogrady
Copy link
Contributor Author

May be a simpler fix to just reverse order of lock acquisition here:

func (m *Manager) UpdateSyncTarget(syncTargetRoot ids.ID) error {
m.workLock.Lock()
defer m.workLock.Unlock()
select {
case <-m.doneChan:
return ErrAlreadyClosed
default:
}
m.syncTargetLock.Lock()
defer m.syncTargetLock.Unlock()

Then just hold onto the updateSyncTarget lock (continue assuming workLock is managed by enqueueLock).

@StephenButtolph StephenButtolph deleted the update-sync-locking branch July 24, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant