Skip to content

Commit

Permalink
Stop async queries if they hit panic (#137)
Browse files Browse the repository at this point in the history
Panic in async queries looked like it was forever running, which
confuses the UI and potentially our logic how many async can we handle.
  • Loading branch information
jakozaur authored May 17, 2024
1 parent 94a0899 commit e7fbb2b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions quesma/quesma/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
fullQuery, columns := q.makeBasicQuery(ctx, queryTranslator, table, simpleQuery, queryInfo, highlighter)
if optAsync != nil {
go func() {
defer recovery.LogPanicWithCtx(ctx)
defer recovery.LogAndHandlePanic(ctx, func() {
optAsync.doneCh <- AsyncSearchWithError{err: errors.New("panic")}
})
q.searchWorker(ctx, *fullQuery, columns, queryTranslator, table, optAsync)
}()
} else {
Expand All @@ -245,7 +247,9 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
columns := []string{}
if optAsync != nil {
go func() {
defer recovery.LogPanicWithCtx(ctx)
defer recovery.LogAndHandlePanic(ctx, func() {
optAsync.doneCh <- AsyncSearchWithError{err: errors.New("panic")}
})
q.searchAggregationWorker(ctx, aggregations, columns, queryTranslator, table, optAsync)
}()
} else {
Expand Down

0 comments on commit e7fbb2b

Please sign in to comment.