Skip to content

Commit

Permalink
Merge pull request #8 from sandeepbhojwani/retry
Browse files Browse the repository at this point in the history
fix for the reconnect issue
  • Loading branch information
vikramraman authored May 9, 2019
2 parents 2ff1217 + d73b8a7 commit bc43231
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 6 additions & 1 deletion backend/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ func (cp *Pool) Get() (net.Conn, error) {
}
}

func (cp *Pool) Return(c net.Conn) {
func (cp *Pool) Return(c net.Conn, failed bool) {

if failed {
<-cp.createsem
return
}
select {
case cp.connections <- c:
default:
Expand Down
4 changes: 1 addition & 3 deletions backend/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ func (w *MetricWriter) Write(rq prompb.WriteRequest) error {
bw := bufio.NewWriter(out)
defer func() {
bw.Flush()
if !fail {
w.pool.Return(out)
}
w.pool.Return(out, fail)
}()
for _, ts := range rq.Timeseries {
if err := w.writeMetrics(bw, &ts); err != nil {
Expand Down

0 comments on commit bc43231

Please sign in to comment.