From eed13be4b75f5bd9c2ed8f529be1eafda9ebee96 Mon Sep 17 00:00:00 2001 From: szywilliam Date: Thu, 2 Jan 2025 21:30:57 +0800 Subject: [PATCH] chore: improve log --- .../apache/ratis/server/raftlog/RaftLogSequentialOps.java | 4 +++- .../org/apache/ratis/server/impl/TransactionManager.java | 8 +------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ratis-server-api/src/main/java/org/apache/ratis/server/raftlog/RaftLogSequentialOps.java b/ratis-server-api/src/main/java/org/apache/ratis/server/raftlog/RaftLogSequentialOps.java index 5e274a6959..5a25728830 100644 --- a/ratis-server-api/src/main/java/org/apache/ratis/server/raftlog/RaftLogSequentialOps.java +++ b/ratis-server-api/src/main/java/org/apache/ratis/server/raftlog/RaftLogSequentialOps.java @@ -79,8 +79,10 @@ OUTPUT runSequentially( // The current thread is already the runner. return operation.get(); } else { + final Throwable cause = new Throwable("The thread already running: " + previous); + cause.setStackTrace(previous.getStackTrace()); throw new IllegalStateException( - name + ": Already running a method by " + previous + ", current=" + current); + name + ": Already running a method by " + previous + ", current=" + current, cause); } } } diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/TransactionManager.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/TransactionManager.java index c33bc26bce..cba310b34d 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/impl/TransactionManager.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/TransactionManager.java @@ -71,12 +71,6 @@ void remove(TermIndex termIndex) { @Override public String toString() { - if (contexts.isEmpty()) { - return name + " "; - } - - final StringBuilder b = new StringBuilder(name); - contexts.forEach((k, v) -> b.append("\n ").append(k).append(": initialized? ").append(v.isInitialized())); - return b.toString(); + return name + ":size=" + contexts.size(); } } \ No newline at end of file