MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / infinitelyRetry

Method infinitelyRetry

dgraph/cmd/live/batch.go:131–156  ·  view source on GitHub ↗
(req *request)

Source from the content-addressed store, hash-verified

129}
130
131func (l *loader) infinitelyRetry(req *request) {
132 defer l.retryRequestsWg.Done()
133 defer l.deregister(req)
134 nretries := 1
135 for i := time.Millisecond; ; i *= 2 {
136 err := l.mutate(req)
137 if err == nil {
138 if opt.verbose {
139 fmt.Printf("Transaction succeeded after %s.\n",
140 english.Plural(nretries, "retry", "retries"))
141 }
142 atomic.AddUint64(&l.nquads, uint64(len(req.Set)))
143 atomic.AddUint64(&l.txns, 1)
144 return
145 }
146 nretries++
147 handleError(err, true)
148 atomic.AddUint64(&l.aborts, 1)
149 if i >= 10*time.Second {
150 i = 10 * time.Second
151 }
152 l.deregister(req)
153 time.Sleep(i)
154 l.addConflictKeys(req)
155 }
156}
157
158func (l *loader) mutate(req *request) error {
159 atomic.AddInt32(&l.inflight, 1)

Callers 1

requestMethod · 0.95

Calls 5

deregisterMethod · 0.95
mutateMethod · 0.95
addConflictKeysMethod · 0.95
handleErrorFunction · 0.85
DoneMethod · 0.45

Tested by

no test coverage detected