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

sched_worker.go has dead lock #5267

Closed
gavin-ygy opened this issue Dec 29, 2020 · 1 comment
Closed

sched_worker.go has dead lock #5267

gavin-ygy opened this issue Dec 29, 2020 · 1 comment

Comments

@gavin-ygy
Copy link

Describe the bug
if the miner can't add new worker anymore.

Version (run lotus version):
v1.4.0
Additional context
sector-storage/sched_worker.go
func (sh *scheduler) runWorker(ctx context.Context, w Worker) error {
info, err := w.Info(ctx)
if err != nil {
return xerrors.Errorf("getting worker info: %w", err)
}

sessID, err := w.Session(ctx)
if err != nil {
	return xerrors.Errorf("getting worker session: %w", err)
}
if sessID == ClosedWorkerID {
	return xerrors.Errorf("worker already closed")
}

worker := &workerHandle{
	workerRpc: w,
	info:      info,

	preparing: &activeResources{},
	active:    &activeResources{},
	enabled:   true,

	closingMgr: make(chan struct{}),
	closedMgr:  make(chan struct{}),
}

wid := WorkerID(sessID)

sh.workersLk.Lock()
_, exist := sh.workers[wid]
if exist {
	log.Warnw("duplicated worker added", "id", wid)

	sh.workersLk.Unlock()  //****************Gavin adding this line and fix the bug!

	// this is ok, we're already handling this worker in a different goroutine
	return nil
}
   sh.workers[wid] = worker
sh.workersLk.Unlock()

//...
}

@magik6k
Copy link
Contributor

magik6k commented Jan 5, 2021

Good catch! Fixed in #5251

@magik6k magik6k closed this as completed Jan 5, 2021
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