Skip to content

Commit 801ffee

Browse files
deepkaranDeepkaran Salooja
authored andcommitted
MB-25156 scan-coordinator: fix stats update panic with drop index
scan_coordinator has race condition in stats update with drop index. drop index can cleanup the stats while the scan has acquired the snapshot and will execute the request. In all such cases, the stat update needs to be skipped. Change-Id: If03ec2ebce841255074eb7efc578bbb3a0432cf2
1 parent 1f522c9 commit 801ffee

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

secondary/indexer/scan_coordinator.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,16 +1481,19 @@ func (s *scanCoordinator) serverCallback(protoReq interface{}, conn net.Conn,
14811481
return
14821482
}
14831483

1484-
req.Stats.scanReqAllocDuration.Add(time.Now().Sub(atime).Nanoseconds())
1484+
if req.Stats != nil {
1485+
req.Stats.scanReqAllocDuration.Add(time.Now().Sub(atime).Nanoseconds())
1486+
}
14851487

14861488
if err := s.isScanAllowed(*req.Consistency, req); err != nil {
14871489
s.tryRespondWithError(w, req, err)
14881490
return
14891491
}
14901492

1491-
req.Stats.numRequests.Add(1)
1492-
1493-
req.Stats.scanReqInitDuration.Add(time.Now().Sub(ttime).Nanoseconds())
1493+
if req.Stats != nil {
1494+
req.Stats.numRequests.Add(1)
1495+
req.Stats.scanReqInitDuration.Add(time.Now().Sub(ttime).Nanoseconds())
1496+
}
14941497

14951498
t0 := time.Now()
14961499
is, err := s.getRequestedIndexSnapshot(req)
@@ -1506,7 +1509,9 @@ func (s *scanCoordinator) serverCallback(protoReq interface{}, conn net.Conn,
15061509
})
15071510

15081511
defer func() {
1509-
req.Stats.scanReqDuration.Add(time.Now().Sub(ttime).Nanoseconds())
1512+
if req.Stats != nil {
1513+
req.Stats.scanReqDuration.Add(time.Now().Sub(ttime).Nanoseconds())
1514+
}
15101515
}()
15111516

15121517
s.processRequest(req, w, is, t0)
@@ -1546,10 +1551,12 @@ func (s *scanCoordinator) handleScanRequest(req *ScanRequest, w ScanResponseWrit
15461551
err := scanPipeline.Execute()
15471552
scanTime := time.Now().Sub(t0)
15481553

1549-
req.Stats.numRowsReturned.Add(int64(scanPipeline.RowsReturned()))
1550-
req.Stats.scanBytesRead.Add(int64(scanPipeline.BytesRead()))
1551-
req.Stats.scanDuration.Add(scanTime.Nanoseconds())
1552-
req.Stats.scanWaitDuration.Add(waitTime.Nanoseconds())
1554+
if req.Stats != nil {
1555+
req.Stats.numRowsReturned.Add(int64(scanPipeline.RowsReturned()))
1556+
req.Stats.scanBytesRead.Add(int64(scanPipeline.BytesRead()))
1557+
req.Stats.scanDuration.Add(scanTime.Nanoseconds())
1558+
req.Stats.scanWaitDuration.Add(waitTime.Nanoseconds())
1559+
}
15531560

15541561
if err != nil {
15551562
status := fmt.Sprintf("(error = %s)", err)

0 commit comments

Comments
 (0)