mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 11:24:44 -07:00
Do snapshot setup in go routine as well for checkMsgs
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -1185,19 +1185,23 @@ func (s *Server) jsStreamSnapshotRequest(sub *subscription, c *client, subject,
|
||||
return
|
||||
}
|
||||
|
||||
sr, err := mset.Snapshot(0, !req.NoConsumers, req.CheckMsgs)
|
||||
if err != nil {
|
||||
resp.Error = jsError(err)
|
||||
s.sendAPIResponse(c, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
}
|
||||
// We will do the snapshot in a go routine as well since check msgs may
|
||||
// stall this go routine.
|
||||
go func() {
|
||||
sr, err := mset.Snapshot(0, !req.NoConsumers, req.CheckMsgs)
|
||||
if err != nil {
|
||||
resp.Error = jsError(err)
|
||||
s.sendAPIResponse(c, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
}
|
||||
|
||||
resp.NumBlks = sr.NumBlks
|
||||
resp.BlkSize = sr.BlkSize
|
||||
s.sendAPIResponse(c, subject, reply, string(msg), s.jsonResponse(resp))
|
||||
resp.NumBlks = sr.NumBlks
|
||||
resp.BlkSize = sr.BlkSize
|
||||
s.sendAPIResponse(c, subject, reply, string(msg), s.jsonResponse(resp))
|
||||
|
||||
// Now do the real streaming in a separate go routine.
|
||||
go s.streamSnapshot(c, mset, sr, &req)
|
||||
// Now do the real streaming.
|
||||
s.streamSnapshot(c, mset, sr, &req)
|
||||
}()
|
||||
}
|
||||
|
||||
// Default chunk size for now.
|
||||
|
||||
Reference in New Issue
Block a user