Improve 'internal error' message caused by 'receive.timeout'

With this commit when the value of 'receive.timeout' is small
and Gerrit cancel the running task successfully Gerrit will
feedback with:

'remote: error: internal error while processing changes (timeout 2772ms, cancelled)'

comparing with the old one:

'remote: error: internal error while processing changes'

Admin now can get quickly what has happened to this push,
the root reason and what value of receive.timeout would be better.

Change-Id: If082a71a4a22aa12d10e4b34f6ae05240581fab1
This commit is contained in:
Bruce Zu
2013-01-28 16:22:46 +08:00
parent 4a9714b86a
commit 845689833e
2 changed files with 11 additions and 5 deletions

View File

@@ -183,6 +183,7 @@ public class MultiProgressMonitor {
final TimeUnit timeoutUnit) throws ExecutionException {
long overallStart = System.nanoTime();
long deadline;
String detailMessage = "";
if (timeoutTime > 0) {
deadline = overallStart + NANOSECONDS.convert(timeoutTime, timeoutUnit);
} else {
@@ -204,10 +205,15 @@ public class MultiProgressMonitor {
long now = System.nanoTime();
if (deadline > 0 && now > deadline) {
log.warn(String.format(
"MultiProgressMonitor worker killed after %sms",
TimeUnit.MILLISECONDS.convert(now - overallStart, NANOSECONDS)));
workerFuture.cancel(true);
if (workerFuture.isCancelled()) {
detailMessage = String.format(
"(timeout %sms, cancelled)",
TimeUnit.MILLISECONDS.convert(now - deadline, NANOSECONDS));
log.warn(String.format(
"MultiProgressMonitor worker killed after %sms" + detailMessage, //
TimeUnit.MILLISECONDS.convert(now - overallStart, NANOSECONDS)));
}
break;
}
@@ -235,7 +241,7 @@ public class MultiProgressMonitor {
} catch (InterruptedException e) {
throw new ExecutionException(e);
} catch (CancellationException e) {
throw new ExecutionException(e);
throw new ExecutionException(detailMessage, e);
} catch (TimeoutException e) {
workerFuture.cancel(true);
throw new ExecutionException(e);