Poison


  • 首页

  • 归档

  • 标签

  • 搜索
close
Poison

CLOSE_WAIT

发表于 2022-10-08

最近查了个与 CLOSE_WAIT 状态有关的问题,在此简要记录。首先背景是在业务高峰期时由于同事误操作下掉了某组应用一半以上的后端服务器,导致流量全部打在剩余的后端服务器上,由于剩余的后端服务器不足以支撑所有的流量,接口响应时间开始增大,Tomcat 线程池中的活跃线程数迅速增加至 200,接着就是负载均衡侧对后端服务器的健康检查不能成功,检活失败次数达到设置的检活阈值后即自动将不健康的后端服务器进行了摘除,随着后端服务器的摘除,剩余的后端服务器更加不能支撑线上流量,最后导致该组应用的所有后端服务器被摘除。收到告警后同事立即增加了线上后端服务器实例个数,但是服务并没有恢复,不仅之前被负载均衡摘除的后端服务器没有及时恢复,新加入的后端服务器在短暂的服务后也被负载均衡判定为不健康随即被摘除。整个服务面临的情况就是在业务高峰期无法进行冷启动的问题,随即同事在应用层对相关核心接口进行了限流以尝试逐步恢复服务,但是接口限流后服务也没有立即恢复,而是在四十分钟后,服务逐步恢复。由于事故发生时我正在外面做核酸检测,所以并没参与处理此次线上事故。在该次事故后,我从事故发生时采集到的相关监控数据来尝试还原事故现场并分析服务不能快速恢复的原因。

阅读全文 »
Poison

MyBatis #2709

发表于 2022-10-01
Reference

Fix a race condition caused by other threads calling mapper methods while mappedStatements are being constructed by tianshuang · Pull Request #2709 · mybatis/mybatis-3 · GitHub
GitHub - tianshuang/mybatis-race-condition
HashMap resize() while single thread writing and multiple threads reading - Stack Overflow

Poison

java.lang.NoSuchFieldError: Companion

发表于 2022-09-13

今天查了个与 OkHttp Maven 依赖相关的问题,本文做简单记录。起因是我们遇到一个 OkHttp 3.14.2 中存在的 bug,且此 bug 在新版本中已得到修复,于是我们将 OkHttp 升级到了最新的稳定版 4.10.0。且升级前还确认了 Upgrading to OkHttp 4 - OkHttp 中提到的不兼容的改动与该工程无关。升级后 CI 各个环境发布均正常,直到同事反馈本地工程启动报错:

1
2
3
4
5
Caused by: java.lang.NoSuchFieldError: Companion
at okhttp3.internal.Util.<clinit>(Util.kt:70) ~[okhttp-4.10.0.jar:?]
at okhttp3.internal.concurrent.TaskRunner.<clinit>(TaskRunner.kt:309) ~[okhttp-4.10.0.jar:?]
at okhttp3.ConnectionPool.<init>(ConnectionPool.kt:41) ~[okhttp-4.10.0.jar:?]
at okhttp3.ConnectionPool.<init>(ConnectionPool.kt:47) ~[okhttp-4.10.0.jar:?]
阅读全文 »
Poison

RestartClassLoader

发表于 2022-09-05

今天帮同事查了个问题,在此简单记录。起因是同事在本地开发一段时间后会触发这样的异常:

1
2
3
4
5
2022-09-05 18:10:28.172 ERROR - [nio-8079-exec-2] o.a.c.c.C.[.[.[.[dispatcherServlet]:175 - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: me.tianshuang.dto.BizDTO cannot be cast to me.tianshuang.dto.BizDTO] with root cause

java.lang.ClassCastException: me.tianshuang.dto.BizDTO cannot be cast to me.tianshuang.dto.BizDTO
at net.sf.cglib.empty.Object$$BeanCopierByCGLIB$$ac6a32c6.copy(<generated>) ~[na:na]
at me.tianshuang.bean.BeanCopy.copy(BeanCopy.java:51) ~[commons-tool-1.0-SNAPSHOT.jar:na]
阅读全文 »
Poison

Allocation Rate

发表于 2022-08-29

今天排查了个内存申请率较高的问题,单个节点上 Allocation Rate 为 700MB/s,Promoted Rate 仅 300KB/s,而通过查看该组应用的历史监控,发现 Allocation Rate 之前从未超过 200MB/s。自最近一个版本发布后,Allocation Rate 翻了几倍,通过 async-profiler 对内存申请进行分析发现为业务中一段类型转换的代码导致,即 String.valueOf(long l) 方法,最后通过优化业务代码实现解决该问题。

2022-09-20

类似地,今天查了个由业务中滥用 RequestMapping 中的正则匹配导致内存申请率高的问题,此时不能直接通过请求的 URL 直接查询出关联的 HandlerMethod,而需要遍历所有的 mapping 去尝试正则匹配,导致内存申请率高,相关源码位于 AbstractHandlerMethodMapping.java at v3.2.18:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Look up the best-matching handler method for the current request.
* If multiple matches are found, the best match is selected.
* @param lookupPath mapping lookup path within the current servlet mapping
* @param request the current request
* @return the best-matching handler method, or {@code null} if no match
* @see #handleMatch(Object, String, HttpServletRequest)
* @see #handleNoMatch(Set, String, HttpServletRequest)
*/
protected HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletRequest request) throws Exception {
List<Match> matches = new ArrayList<Match>();
List<T> directPathMatches = this.urlMap.get(lookupPath);
if (directPathMatches != null) {
addMatchingMappings(directPathMatches, matches, request);
}
if (matches.isEmpty()) {
// No choice but to go through all mappings...
addMatchingMappings(this.handlerMethods.keySet(), matches, request);
}

if (!matches.isEmpty()) {
// ...
return bestMatch.handlerMethod;
}
else {
return handleNoMatch(handlerMethods.keySet(), lookupPath, request);
}
}

private void addMatchingMappings(Collection<T> mappings, List<Match> matches, HttpServletRequest request) {
for (T mapping : mappings) {
T match = getMatchingMapping(mapping, request);
if (match != null) {
matches.add(new Match(match, this.handlerMethods.get(mapping)));
}
}
}
阅读全文 »
1234…26

130 日志
119 标签
GitHub LeetCode
© 2025 Poison 蜀ICP备16000644号
由 Hexo 强力驱动
主题 - NexT.Mist