-
-
Notifications
You must be signed in to change notification settings - Fork 87
Closed
Labels
Milestone
Description
Fix: Reduce thread blocking by double null check instead of synchronizing on Method object #521
We observed severe thread blocking issues in production: 980+ threads were blocked at OgnlRuntime.invokeMethod with the state BLOCKED (on object monitor), waiting to lock java.lang.reflect.Method objects.
# 980 threads blocked
"default-17571" #91915 prio=5 os_prio=0 tid=0x00007f7b7c05d800 nid=0x167f9 waiting for monitor entry [0x00007f757f772000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.apache.ibatis.ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:1151)
- waiting to lock <0x00000004a55aaf48> (a java.lang.reflect.Method)
at org.apache.ibatis.ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:2146)
at org.apache.ibatis.ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:66)
at org.apache.ibatis.ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:160)
at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:3356)
...
# got method lock thread
"HSFBizProcessor-DEFAULT-6-thread-5179" #90650 daemon prio=10 os_prio=0 tid=0x00007f794c319000 nid=0x16214 waiting for monitor entry [0x00007f758366e000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.apache.ibatis.ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:1151)
- locked <0x00000004a55aaf48> (a java.lang.reflect.Method)
at org.apache.ibatis.ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:2146)
at org.apache.ibatis.ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:66)
at org.apache.ibatis.ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:160)
at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:3356)
...
Root cause:
- Direct synchronization on
Methodobjects leads to heavy thread contention — all threads competing to execute method access checks must wait for the sameMethodmonitor, which severely degrades system concurrency and performance.
Reactions are currently unavailable