Skip to content

Commit

Permalink
sched: re-register worker windows after re-enabling correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Oct 30, 2020
1 parent f90a387 commit 69e44eb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
18 changes: 18 additions & 0 deletions extern/sector-storage/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ func TestReenableWorker(t *testing.T) {

time.Sleep(time.Millisecond * 100)

i, _ := m.sched.Info(ctx)
require.Len(t, i.(SchedDiagInfo).OpenWindows, 2)

// disable
atomic.StoreInt64(&w.testDisable, 1)

Expand All @@ -421,6 +424,9 @@ func TestReenableWorker(t *testing.T) {
}
require.False(t, m.WorkerStats()[w.session].Enabled)

i, _ = m.sched.Info(ctx)
require.Len(t, i.(SchedDiagInfo).OpenWindows, 0)

// reenable
atomic.StoreInt64(&w.testDisable, 0)

Expand All @@ -432,4 +438,16 @@ func TestReenableWorker(t *testing.T) {
time.Sleep(time.Millisecond * 3)
}
require.True(t, m.WorkerStats()[w.session].Enabled)

for i := 0; i < 100; i++ {
info, _ := m.sched.Info(ctx)
if len(info.(SchedDiagInfo).OpenWindows) != 0 {
break
}

time.Sleep(time.Millisecond * 3)
}

i, _ = m.sched.Info(ctx)
require.Len(t, i.(SchedDiagInfo).OpenWindows, 2)
}
15 changes: 11 additions & 4 deletions extern/sector-storage/sched_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,17 @@ func (sw *schedWorker) handleWorker() {
}

// session looks good
sched.workersLk.Lock()
worker.enabled = true
// we'll send window requests on the next loop
sched.workersLk.Unlock()
{
sched.workersLk.Lock()
enabled := worker.enabled
worker.enabled = true
sched.workersLk.Unlock()

if !enabled {
// go send window requests
break
}
}

// wait for more tasks to be assigned by the main scheduler or for the worker
// to finish precessing a task
Expand Down

0 comments on commit 69e44eb

Please sign in to comment.