[Erlang29]进程收到不是期望的消息时怎么办?
handle_info({add,X},Sum) ->
{noreply,Sum+X};
{add,X}------->{plus,X}
在A进程中存着大量的{plus,X}信息,使得这个进程的内存占用也变得异常的大。
1.你可以记录这些消息:
1a.) as info
1b.) as warning
1c.) as error
2.对消息进行记数,然后对记数做怎样的处理?
3.直接忽略它们,不做trace?
4.让server直接crash掉?
I tend to go the log route. There isn't a super good reason, but the way
I think about it is a bit of probability. When do I send messages to the wrong process? A few ideas are: - Manual debugging
- Typoes
- A Refactoring gone bad
- Initial design got messed up
- Erroneous third-party code that doesn't come from my precise
development right away. Then the question is what are the consequences I want. - Manual debugging: do nothing, I'm poking around
- Typoes: I have to know about these ASAP
- Refactoring gone bad: I have to know about these ASAP
- Initial design got messed up: Something has to be loud and bad
- Third party code: I want the third party to suffer. For these reasons, I tend to take the following approach: - In handle_call/3, I log the event with a string a bit like
"mod=MYMOD at=handle_call warning=unexpected_call msg=~p" and then
return `{noreply, State}` to force the caller to crash after a
timeout. It's their fault, not mine.
- In other callbacks, just log similar messages, replacing
at=handle_call with at=handle_cast|info and
warning=unexpected_cast|info. I can, from time to time, look at logs for 'warning=unexpected_*' in
logs and see if something is going weird. If it's something happening rarely, I'm gonna have traces, but without
the weird failures (unless it's a call). If it's something frequent,
bugs will either show themselves differently, the log volume will be
very high, and so on. It tends to give me what I need given the circumstances. It's not always
as loud as I'd expect (except for calls, which is ideal), but it tends
to give me enough visibility for the occasional stray message, without
compromising service levels.
handlle_call(Msg,_From,State) ->
log:("mod=~p at=handle_call warning=unexpected_call msg=~p",[?MOdule,Msg]),
{noreply, State};
强制调用者Crash,这是他们的错,不能怪我.然后反复查看Log中是不是存在'warning=unexpected_*'信息。
Running Dialyzer on my codebase:

[Erlang29]进程收到不是期望的消息时怎么办?的更多相关文章
- Linux进程间通信--进程,信号,管道,消息队列,信号量,共享内存
Linux进程间通信--进程,信号,管道,消息队列,信号量,共享内存 参考:<linux编程从入门到精通>,<Linux C程序设计大全>,<unix环境高级编程> ...
- android 进程/线程管理(四)----消息机制的思考(自定义消息机制)
关于android消息机制 已经写了3篇文章了,想要结束这个系列,总觉得少了点什么? 于是我就在想,android为什么要这个设计消息机制,使用消息机制是现在操作系统基本都会有的特点. 可是andro ...
- WPF 加载 WINFORM控件 异常: 调度程序进程已挂起,但消息仍在处理中
在加载TradeAtServer的统计中的 单个合约盈亏情况 异常:,调度程序进程已挂起,但消息仍在处理中 发现可能是属性设置引发的问题 比如DateTimePikcer.Value+= set, g ...
- BCB 如何让Application收到SendMessage发送来的消息
一般,都是通过添加一个ApplicationEvent组件就可以接收到PostMessage发来的消息,那么如何收到SendMessage发来的消息呢? https://stackoverflow.c ...
- 在Boss直聘上投简历时,怎样保证有新消息时能及时收到
最近在Boss直聘上投简历,偶尔会有HR给我发消息,不想在电脑上错过这些消息,但我又不能时时刻刻盯着这个页,怎么办呢? 这时,我想起来,之前做过的Chrome插件,如果检测到Boss直聘上新消息数大于 ...
- 【Azure 服务总线】详解Azure Service Bus SDK中接收消息时设置的maxConcurrentCalls,prefetchCount参数
(Azure Service Bus服务总线的两大类消息处理方式: 队列Queue和主题Topic) 问题描述 使用Service Bus作为企业消息代理,当有大量的数据堆积再Queue或Topic中 ...
- WCF服务调用超时错误:套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的。本地套接字超时是“00:05:30”(已解决)
问题: 线上正式环境调用WCF服务正常,但是每次使用本地测试环境调用WCF服务时长就是出现:套接字连接已中止.这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的.本地套接字超 ...
- Nginx 关于进程数 与CPU核心数相等时,进程间切换的代价是最小的-- 绑定CPU核心
在阅读Nginx模块开发与架构模式一书时: "Nginx 上的进程数 与CPU核心数相等时(最好每个worker进程都绑定特定的CPU核心),进程间切换的代价是最小的;" &am ...
- activeMQ消费消息时网络流量异常大的问题
http://www.cnblogs.com/baibaluo/archive/2012/12/24/2748468.html#2590289 公司有一个应用,多个线程从activeMQ中取消息,随着 ...
随机推荐
- 最小化安装CentOS7,没有ifconfig命令---yum search command_name搜索未知包名
新安装的CentOS7系统,想查询ip的时候,发现没有ifconfig这个命令: -bash: ifconfig: 未找到命令 yum安装: 没有可用软件包 ifconfig 既然知道命令,搜索一下命 ...
- ROS+OPENVPN配置
环境需求:ROS版本:5.26,OPENVPN版本:OpenVPNPortable1.0.3(下载地址http://sourceforge.net/projects/ovpnp/)在WIN7 X64, ...
- CSS布局模型学习
转自:http://www.cnblogs.com/erliang/p/4092192.html CSS布局模型学习 参考链接慕课网:HTML+CSS基础课程 知识基础 1. 样式 内联 嵌入 外 ...
- 操作表单域中的value值
HTML <form action=""> <input type="radio" name="sex" value=&q ...
- React爬坑秘籍(一)——提升渲染性能
React爬坑秘籍(一)--提升渲染性能 ##前言 来到腾讯实习后,有幸八月份开始了腾讯办公助手PC端的开发.因为办公助手主推的是移动端,所以导师也是大胆的让我们实习生来技术选型并开发,他来做code ...
- 29.OGNL与ValueStack(VS)-总结OGNL[重点]
转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html OGNL是Object Graphic Navigation Languag ...
- UGUI 事件穿透规则
UGUI事件分为两大类:点击和拖拽. 点击包括 pointerdown, pointerup. 拖拽包括 begindrag, drag, enddrag. 点击事件无穿透:只会被最上层UI响应,不会 ...
- [OS] 修改屏幕分辨率(用Remote Desktop Connection 或者 用工具:Remote Desktop Connection Manager)
用Remote Desktop Connection Remote Desktop Connection Manager
- MySQL 系列(二)Jdbc
MySQL 系列(二)Jdbc 一.Jdbc 基本操作 import java.sql.Connection; import java.sql.DriverManager; import java.s ...
- Android Studio真机测试失败-----''No target device found"
手机成功连接电脑,并且手机已经设置了开发者模式,但是启动真机还是失败,最后发现居然自己没有配置android sdk的环境变量,配置之后 如果还是不能启动,点击android studio上的tool ...