Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
goroutine で panic すると親プロセスをまきこんで落ちる
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
uji
February 21, 2021
2.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
goroutine で panic すると親プロセスをまきこんで落ちる
uji
February 21, 2021
Transcript
8 slides
goroutine で panic すると 親プロセスをまきこんで落ちる uji @uji_rb
panic とは • 回復不能だと判断された実行時のエラーを発生させる機構 • panicが生じるとプロセスが止まる • 組み込み関数のpanicを呼び出すと発生する
panic のハンドリング • panic は defer + recover でハンドリングできる https://play.golang.org/p/sXEcmsxtV_Z
しかし... goroutine で panic が起こった場合 親プロセスからはハンドリングできない
goroutine の panic • goroutine 内で panic のハンドリングがされていないと 親プロセスごと落ちる https://play.golang.org/p/HUY-sN8PK-X
ぶち当たった問題 • api サーバーで goroutine を使った処理が panic が起こすとプロ セスがまるごと落ちてしまう apiサーバー
メインプロセス リクエスト プロセス リクエスト プロセス リクエスト プロセス リクエスト 子プロセス リクエスト 子プロセス
解決策 • goroutine 内ではなるべく panic が 起こらないようにする (error によるハンドリングを徹底)
• goroutine 内で panic の恐れがある場合は recover 処理を忘れない →汎用的につかえる並列処理実行関数をつくった
参考 • プログラミング言語Go完全入門 https://docs.google.com/presentation/d/1HW3wG8J_Q2536Iu__7HGr_mhurHajC7IOGjCnn3kZmg/edit?usp=sharing
More Decks by uji
See All by uji
【Go ハンズオン】Windows / Linux コマンドを Go で再現
uji
1
140
testdata ディレクトリを活用しよう!
uji
1
520
MCP 公式の Go SDK で QA データ登録アシスタントを作ってみた
uji
0
200
Green Tea GCの動作を紙芝居にしてみる
uji
1
240
Go Proverbs の紹介
uji
2
250
Go標準の暗号ライブラリメンテナンス戦略
uji
3
800
NOT A HOTEL TECH TALK ーSOFTWARE 3.0への道筋ー NEXT Web3 (2024-08-07)
uji
0
290
マネーフォワード ME ブロックチェーン連携機能におけるGoの活用方法
uji
1
340
Goはブロックチェーン領域でなぜ使われ、どのように活躍しているのか
uji
1
840
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
RailsConf 2023
tenderlove
30
1.6k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
430
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
GraphQLとの向き合い方2022年版
quramy
50
15k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
1
240
How to train your dragon (web standard)
notwaldorf
96
6.9k
AI: The stuff that nobody shows you
jnunemaker
PRO
12
1.3k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
990
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
750