Skip to content

Commit

Permalink
perf[orm]: output stack trace with no exception word
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Jul 9, 2024
1 parent 4d01f39 commit a0b6b8c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions orm/src/main/java/com/zfoo/orm/cache/EntityCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -186,12 +187,17 @@ private PNode<PK, E> 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);
}
}
}
Expand Down

0 comments on commit a0b6b8c

Please sign in to comment.