Skip to content

Commit b05c525

Browse files
author
parasssh
authored
dont set n.ops map entries to nil. Instead just delete them (#5551)
A panic was caused because n.ops map entry was set to nil in some cases. Fix is to not set n.ops map entries to nil. Instead, just delete them. Fixed DGRAPH-1573
1 parent b026beb commit b05c525

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

worker/draft.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ func (n *node) startTask(id op) (*y.Closer, error) {
137137
if otherId == opRestore {
138138
return nil, errors.Errorf("another restore operation is already running")
139139
}
140-
// We set to nil so that stopAllTasks doesn't call SignalAndWait again.
141-
n.ops[otherId] = nil
140+
// Remove from map and signal the closer to cancel the operation.
141+
delete(n.ops, otherId)
142142
otherCloser.SignalAndWait()
143143
}
144144
case opSnapshot, opIndexing:
145145
for otherId, otherCloser := range n.ops {
146146
if otherId == opRollup {
147-
// We set to nil so that stopAllTasks doesn't call SignalAndWait again.
148-
n.ops[opRollup] = nil
147+
// Remove from map and signal the closer to cancel the operation.
148+
delete(n.ops, otherId)
149149
otherCloser.SignalAndWait()
150150
} else {
151151
return nil, errors.Errorf("operation %s is already running", otherId)
@@ -182,9 +182,6 @@ func (n *node) stopAllTasks() {
182182
n.opsLock.Lock()
183183
defer n.opsLock.Unlock()
184184
for _, closer := range n.ops {
185-
if closer == nil {
186-
continue
187-
}
188185
closer.SignalAndWait()
189186
}
190187
glog.Infof("Stopped all ongoing registered tasks.")

0 commit comments

Comments
 (0)