MCPcopy
hub / github.com/dgraph-io/dgraph / RetryQuery

Function RetryQuery

testutil/client.go:385–399  ·  view source on GitHub ↗

RetryQuery will retry a query until it succeeds or a non-retryable error is received.

(dg *dgo.Dgraph, q string)

Source from the content-addressed store, hash-verified

383
384// RetryQuery will retry a query until it succeeds or a non-retryable error is received.
385func RetryQuery(dg *dgo.Dgraph, q string) (*api.Response, error) {
386 for {
387 resp, err := dg.NewTxn().Query(context.Background(), q)
388 if err != nil && (strings.Contains(err.Error(), "Please retry") ||
389 strings.Contains(err.Error(), "connection closed") ||
390 strings.Contains(err.Error(), "broken pipe")) {
391 // Retry connection issues because some tests (e.g TestSnapshot) are stopping and
392 // starting alphas.
393 time.Sleep(10 * time.Millisecond)
394 continue
395 }
396
397 return resp, err
398 }
399}
400
401func RetryAlter(dg *dgo.Dgraph, op *api.Operation) error {
402 var err error

Callers 6

backupRestoreTestFunction · 0.92
runQueryFunction · 0.92
TestVectorSchemaFunction · 0.92
runQueryFunction · 0.92
BenchmarkEqFilterFunction · 0.92
verifySnapshotFunction · 0.92

Calls 2

QueryMethod · 0.45
ErrorMethod · 0.45

Tested by 6

backupRestoreTestFunction · 0.74
runQueryFunction · 0.74
TestVectorSchemaFunction · 0.74
runQueryFunction · 0.74
BenchmarkEqFilterFunction · 0.74
verifySnapshotFunction · 0.74