Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-39543] Improve the caller/callee correlation diagnostics #119

Merged
merged 1 commit into from
Oct 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/java/hudson/remoting/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public final RSP call(Channel channel) throws EXC, InterruptedException, IOExcep
final String name = t.getName();
try {
// wait until the response arrives
t.setName(name+" / waiting for "+channel);
t.setName(name+" / waiting for "+channel.getName()+" id="+id);
while(response==null && !channel.isInClosed())
// I don't know exactly when this can happen, as pendingCalls are cleaned up by Channel,
// but in production I've observed that in rare occasion it can block forever, even after a channel
Expand Down Expand Up @@ -233,6 +233,8 @@ public boolean isDone() {

public RSP get() throws InterruptedException, ExecutionException {
synchronized(Request.this) {
String oldThreadName = Thread.currentThread().getName();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe oldThreadName is a bit confuse when you are asking for currentThread()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same variable name used everywhere. I think it's old (thread name) not (old thread) name

Thread.currentThread().setName(oldThreadName+" for "+channel.getName()+" id="+id);
try {
while(response==null) {
if (isCancelled()) {
Expand All @@ -250,6 +252,8 @@ public RSP get() throws InterruptedException, ExecutionException {
// couldn't cancel. ignore.
}
throw e;
} finally {
Thread.currentThread().setName(oldThreadName);
}

if(response.exception!=null)
Expand Down Expand Up @@ -320,7 +324,7 @@ private int calcLastIoId() {

public void run() {
String oldThreadName = Thread.currentThread().getName();
Thread.currentThread().setName(oldThreadName+" for "+channel.getName());
Thread.currentThread().setName(oldThreadName+" for "+channel.getName()+" id="+id);
try {
Command rsp;
CURRENT.set(Request.this);
Expand Down