跳到正文Skip to main content

Java 21 · Tomcat模拟Simulation

失踪的锁The Missing Lock

对照故障与修复Compare the incident and the fix

执行位置 · Carrier slots · 4 / 4 占用1 / 4 占用4 / 4 occupied1 / 4 occupied

待运行Ready queueE 已进入 01E entered 01
现场

新请求排在队列里,队列迟迟没有向前。

原文报告

发布后,压测恢复正常。

From the original article

Load tests returned to normal after deployment.

轨道与任务编号为示意。Lane and task labels are illustrative.

技术细节Technical details

线程快照记录线程当时在哪里执行或等待。堆转储保留当时对象的状态。

堆转储显示锁没有持有者。队首虚拟线程收到了唤醒信号,但其余等待者在 synchronized 内阻塞,占满了四条载体线程。

团队将相关同步块改为显式锁,并把可能阻塞的调用移出临界区。

A thread snapshot records where threads were running or waiting. A heap dump preserves the state of objects at the time.

A heap dump showed that the lock had no owner. The first virtual thread in line had been signalled, but the other waiters blocked inside synchronized and occupied all four carrier threads.

The team replaced the affected synchronized blocks with explicit locks and moved potentially blocking calls outside critical sections.