(ctx context.Context, logger log.Logger, conn clickhouse.Conn, query string, args ...any, )
| 63 | } |
| 64 | |
| 65 | func Exec(ctx context.Context, logger log.Logger, |
| 66 | conn clickhouse.Conn, query string, args ...any, |
| 67 | ) error { |
| 68 | var err error |
| 69 | for i := range 5 { |
| 70 | err = conn.Exec(ctx, query, args...) |
| 71 | if !isRetryableException(err) { |
| 72 | break |
| 73 | } |
| 74 | logger.Info("[exec] retryable error", slog.Any("error", err), slog.Int64("retry", int64(i))) |
| 75 | if i < 4 { |
| 76 | time.Sleep(time.Second * time.Duration(i*5+1)) |
| 77 | } |
| 78 | } |
| 79 | if ex, ok := errors.AsType[*clickhouse.Exception](err); ok { |
| 80 | isMV := strings.Contains(ex.Error(), "while pushing to view") |
| 81 | if chproto.Error(ex.Code) == chproto.ErrIncorrectData { |
| 82 | ex.Message = "REDACTED" |
| 83 | } |
| 84 | if isMV { |
| 85 | return NewViewError(ex) |
| 86 | } |
| 87 | } |
| 88 | return err |
| 89 | } |
| 90 | |
| 91 | func Query(ctx context.Context, logger log.Logger, |
| 92 | conn clickhouse.Conn, query string, args ...any, |
no test coverage detected