mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-15 08:41:02 +00:00
return HTTP status code: 400 (Bad Request) when ingest values are (#2047)
out of range. Previously internal server error was returned. This is to allow for ingest to continue while logging bad values instead of stopping ingest as we do when there is a server error.
This commit is contained in:
parent
d63d2492b9
commit
43a61d87b2
4 changed files with 15 additions and 8 deletions
|
|
@ -700,7 +700,9 @@ func (b *Batch) Import() error {
|
|||
// import int data.
|
||||
err = b.doImport(frags, clearFrags)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "doing import")
|
||||
// doImport actually imports the ingested data. An error here, means an error with the value that is trying to be ingested.
|
||||
// We log the error, so we can continue ingesting. Returning would stop the ingest.
|
||||
b.log.Printf("error importing batch: %v", err)
|
||||
}
|
||||
b.log.Printf("importing fragments took %v", time.Since(makeTime))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -921,7 +921,6 @@ func (c *Client) doRequest(host *pnet.URI, method, path string, headers map[stri
|
|||
if err != nil {
|
||||
return resp.StatusCode, nil, errors.Wrap(err, "reading response body")
|
||||
}
|
||||
|
||||
switch {
|
||||
case resp.StatusCode >= 200 && resp.StatusCode < 300:
|
||||
// [200, 300): OK
|
||||
|
|
@ -944,9 +943,8 @@ func (c *Client) doRequest(host *pnet.URI, method, path string, headers map[stri
|
|||
sleepTime = time.Duration(1<<uint(retry))*time.Second + time.Duration(rand.Intn(1000))*time.Millisecond
|
||||
}
|
||||
|
||||
case resp.StatusCode > 400 && resp.StatusCode < 500:
|
||||
// Pilosa nodes sometimes return 400, we retry in that case.
|
||||
// (400, 500): No need to retry in other 4xx cases.
|
||||
case resp.StatusCode >= 400 && resp.StatusCode < 500:
|
||||
// don't retry any 400 level errors
|
||||
return resp.StatusCode, nil, errors.New(strings.TrimSpace(buf.String()))
|
||||
|
||||
case resp.StatusCode == 503:
|
||||
|
|
|
|||
4
field.go
4
field.go
|
|
@ -1764,9 +1764,9 @@ func (f *Field) importValue(qcx *Qcx, columnIDs []uint64, values []int64, shard
|
|||
for i := range columnIDs {
|
||||
columnID, value := columnIDs[i], values[i]
|
||||
if value > bsig.Max {
|
||||
return fmt.Errorf("%v, imported value = %v, columnID = %v", ErrBSIGroupValueTooHigh, value, columnID)
|
||||
return errors.Wrap(ErrBSIGroupValueTooHigh, fmt.Sprintf("value = %v, columnID = %v", value, columnID))
|
||||
} else if value < bsig.Min {
|
||||
return fmt.Errorf("%v, imported value = %v, columnID = %v", ErrBSIGroupValueTooLow, value, columnID)
|
||||
return errors.Wrap(ErrBSIGroupValueTooLow, fmt.Sprintf("value = %v, columnID = %v", value, columnID))
|
||||
}
|
||||
if value > max {
|
||||
max = value
|
||||
|
|
|
|||
|
|
@ -1133,7 +1133,6 @@ func (h *Handler) handlePostQuery(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var err error
|
||||
err, _ = qerr.(error)
|
||||
|
||||
if err != nil || !ok {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
e := h.writeQueryResponse(w, r, &QueryResponse{Err: err})
|
||||
|
|
@ -2972,6 +2971,8 @@ func (h *Handler) handlePostImportAtomicRecord(w http.ResponseWriter, r *http.Re
|
|||
switch errors.Cause(err) {
|
||||
case ErrClusterDoesNotOwnShard, ErrPreconditionFailed:
|
||||
http.Error(w, err.Error(), http.StatusPreconditionFailed)
|
||||
case ErrBSIGroupValueTooLow, ErrBSIGroupValueTooHigh, ErrDecimalOutOfRange:
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
|
@ -3045,9 +3046,12 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) {
|
|||
switch errors.Cause(err) {
|
||||
case ErrClusterDoesNotOwnShard, ErrPreconditionFailed:
|
||||
http.Error(w, err.Error(), http.StatusPreconditionFailed)
|
||||
case ErrBSIGroupValueTooLow, ErrBSIGroupValueTooHigh, ErrDecimalOutOfRange:
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
err := qcx.Finish()
|
||||
|
|
@ -3071,6 +3075,8 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) {
|
|||
switch errors.Cause(err) {
|
||||
case ErrClusterDoesNotOwnShard, ErrPreconditionFailed:
|
||||
http.Error(w, err.Error(), http.StatusPreconditionFailed)
|
||||
case ErrBSIGroupValueTooLow, ErrBSIGroupValueTooHigh, ErrDecimalOutOfRange:
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
|
@ -3626,6 +3632,7 @@ func (h *Handler) handleResetIDAlloc(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, "index name is required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
err := h.api.ResetIDAlloc(indexName)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("resetting ID allocation: %v", err.Error()), http.StatusBadRequest)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue