Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add defer recover for go routines to prevent abnormal crash #1419

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

nic-chen
Copy link
Member

@nic-chen nic-chen commented Feb 3, 2021

Please answer these questions before submitting a pull request


Bugfix

  • Description

Manager API may crash without any logs.
In gin, we use filter.RecoverHandler() to prevent crash.
But we can not control the exceptions in other go-routines.

  • How to fix?

add defer recover() for go routines to prevent abnormal crash

@codecov-io
Copy link

Codecov Report

Merging #1419 (fc0db75) into master (0a0a42a) will decrease coverage by 21.32%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1419       +/-   ##
===========================================
- Coverage   66.59%   45.27%   -21.33%     
===========================================
  Files          44       36        -8     
  Lines        2937     2531      -406     
===========================================
- Hits         1956     1146      -810     
- Misses        744     1218      +474     
+ Partials      237      167       -70     
Impacted Files Coverage Δ
api/internal/utils/runtime/runtime.go 64.28% <64.28%> (ø)
api/internal/core/store/store.go 81.32% <100.00%> (-4.74%) ⬇️
api/internal/filter/request_id.go 0.00% <0.00%> (-100.00%) ⬇️
api/internal/core/entity/entity.go 0.00% <0.00%> (-100.00%) ⬇️
api/internal/core/store/storehub.go 0.00% <0.00%> (-70.41%) ⬇️
api/internal/filter/cors.go 0.00% <0.00%> (-66.67%) ⬇️
api/internal/filter/schema.go 0.00% <0.00%> (-55.47%) ⬇️
api/internal/handler/upstream/upstream.go 28.81% <0.00%> (-54.24%) ⬇️
api/internal/utils/consts/api_error.go 0.00% <0.00%> (-50.00%) ⬇️
api/internal/handler/data_loader/route_import.go 27.41% <0.00%> (-37.50%) ⬇️
... and 32 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a0a42a...fc0db75. Read the comment docs.

@nic-chen nic-chen requested a review from tokers February 4, 2021 13:12
@juzhiyuan juzhiyuan merged commit 0b5a687 into apache:master Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Add defer recover for all go routines to prevent abnormal crash of manager-api
5 participants