From a0b6b8c57376719f9fa82c3fb1c8d53b2180088a Mon Sep 17 00:00:00 2001 From: godotg Date: Tue, 9 Jul 2024 17:01:31 +0800 Subject: [PATCH] perf[orm]: output stack trace with no exception word --- .../main/java/com/zfoo/orm/cache/EntityCache.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/orm/src/main/java/com/zfoo/orm/cache/EntityCache.java b/orm/src/main/java/com/zfoo/orm/cache/EntityCache.java index be9c2e101..f749ceea3 100644 --- a/orm/src/main/java/com/zfoo/orm/cache/EntityCache.java +++ b/orm/src/main/java/com/zfoo/orm/cache/EntityCache.java @@ -30,6 +30,7 @@ import com.zfoo.protocol.exception.RunException; import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.util.AssertionUtils; +import com.zfoo.protocol.util.FileUtils; import com.zfoo.protocol.util.GraalVmUtils; import com.zfoo.protocol.util.ThreadUtils; import com.zfoo.scheduler.manager.SchedulerBus; @@ -186,12 +187,17 @@ private PNode fetchCachePnode(E entity, boolean safe) { cachePnode.setThreadId(currentThreadId); } else { var pnodeThread = ThreadUtils.findThread(pnodeThreadId); + var builder = new StringBuilder(); + for(var stack : Thread.currentThread().getStackTrace()) { + builder.append(FileUtils.LS).append(stack); + } // 有并发写风险,第一次更新文档的线程和第2次更新更新文档的线程不相等 if (pnodeThread == null) { - logger.warn("orm concurrent write warning", new RunException("[{}][id:{}] first update [threadId:{}], second update [threadId:{}]", entity.getClass().getSimpleName(), entity.id(), pnodeThreadId, currentThreadId)); + logger.warn("[{}][id:{}] concurrent write warning, first update [threadId:{}], second update [threadId:{}], current stack trace as following:{}" + , entity.getClass().getSimpleName(), entity.id(), pnodeThreadId, currentThreadId, builder); } else { - logger.warn("orm concurrent write warning", new RunException("[{}][id:{}] first update [threadId:{}][threadName:{}], second update [threadId:{}][threadName:{}]" - , entity.getClass().getSimpleName(), entity.id(), pnodeThreadId, pnodeThread.getName(), currentThreadId, Thread.currentThread().getName())); + logger.warn("[{}][id:{}] concurrent write warning, first update [threadId:{}][threadName:{}], second update [threadId:{}][threadName:{}], current stack trace as following:{}" + , entity.getClass().getSimpleName(), entity.id(), pnodeThreadId, pnodeThread.getName(), currentThreadId, Thread.currentThread().getName(), builder); } } }