RetryMutation will retry a mutation until it succeeds or a non-retryable error is received. The mutation should have CommitNow set to true.
(dg *dgo.Dgraph, mu *api.Mutation)
| 430 | // RetryMutation will retry a mutation until it succeeds or a non-retryable error is received. |
| 431 | // The mutation should have CommitNow set to true. |
| 432 | func RetryMutation(dg *dgo.Dgraph, mu *api.Mutation) error { |
| 433 | for { |
| 434 | _, err := dg.NewTxn().Mutate(context.Background(), mu) |
| 435 | if err != nil && (strings.Contains(err.Error(), "Please retry") || |
| 436 | strings.Contains(err.Error(), "Tablet isn't being served by this instance") || |
| 437 | strings.Contains(err.Error(), "connection closed")) { |
| 438 | // Retry connection issues because some tests (e.g TestSnapshot) are stopping and |
| 439 | // starting alphas. |
| 440 | time.Sleep(10 * time.Millisecond) |
| 441 | continue |
| 442 | } |
| 443 | return err |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | // LoginParams stores the information needed to perform a login request. |
| 448 | type LoginParams struct { |