Skip to content

Commit

Permalink
oxia: add write latency for writeStream (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattisonchao authored Aug 28, 2024
1 parent b0988d2 commit a186246
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/leader_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,11 +873,13 @@ func (lc *leaderController) handleWriteStream(stream proto.OxiaClient_WriteStrea
return
}

timer := lc.writeLatencyHisto.Timer()
slog.Debug("Got request in stream",
slog.Any("req", req))

offset, timestamp, err1 := lc.appendToWalStreamRequest(stream.Context(), req)
if err1 != nil {
timer.Done()
closeCh <- err1
return
}
Expand All @@ -886,14 +888,17 @@ func (lc *leaderController) handleWriteStream(stream proto.OxiaClient_WriteStrea
return lc.db.ProcessWrite(req, offset, timestamp, SessionUpdateOperationCallback)
})
if err2 != nil {
timer.Done()
closeCh <- err2
return
}

if err3 := stream.Send(resp); err3 != nil {
timer.Done()
closeCh <- err3
return
}
timer.Done()
}
}

Expand Down

0 comments on commit a186246

Please sign in to comment.