예제 #1
0
 private void checkThreads() {
   Map<Thread, Long> requestThreads = new HashMap<>();
   synchronized (_requestThreads) {
     requestThreads.putAll(_requestThreads);
   }
   if (!requestThreads.isEmpty()) {
     int deadlocksCount = 0;
     Map<Thread, StackTraceElement[]> traces = null;
     for (Thread thread : requestThreads.keySet()) {
       Long time = requestThreads.get(thread);
       if (time != null) {
         time = System.currentTimeMillis() - time;
         if (time > _maximumRequestWarnTime / 2 && _warnTraces.get(thread) == null) {
           if (traces == null) {
             traces = Thread.getAllStackTraces();
           }
           Map<Thread, String> names = getCurrentThreadNames(traces.keySet());
           _warnTraces.put(thread, traces);
           _warnTracesNames.put(thread, names);
         }
         if (time > _maximumRequestErrorTime / 2 && _errorTraces.get(thread) == null) {
           if (traces == null) {
             traces = Thread.getAllStackTraces();
           }
           Map<Thread, String> names = getCurrentThreadNames(traces.keySet());
           _errorTraces.put(thread, traces);
           _errorTracesNames.put(thread, names);
         }
         if (time > _maximumRequestFatalTime && _fatalTraces.get(thread) == null) {
           if (traces == null) {
             traces = Thread.getAllStackTraces();
           }
           Map<Thread, String> names = getCurrentThreadNames(traces.keySet());
           _fatalTraces.put(thread, traces);
           _fatalTracesNames.put(thread, names);
           StringBuilder sb = new StringBuilder();
           sb.append("Request is taking too long, possible deadlock: ");
           sb.append(time);
           sb.append(" ms ");
           sb.append(stringFromTracesAndNames(traces, names));
           sb.append("EC info:\n");
           sb.append(ERXEC.outstandingLockDescription());
           sb.append("OSC info:\n");
           sb.append(ERXObjectStoreCoordinator.outstandingLockDescription());
           log.error(sb.toString());
           deadlocksCount++;
         }
       }
     }
     listener.deadlock(deadlocksCount);
   }
 }
예제 #2
0
 /**
  * Returns a list of the traces of open editing context locks. This is only useful if
  * er.extensions.ERXApplication.traceOpenEditingContextLocks is enabled and
  * er.extensions.ERXOpenEditingContextLocksPassword is set.
  *
  * @return list of lock traces
  */
 public WOActionResults showOpenEditingContextLockTracesAction() {
   if (canPerformActionWithPasswordKey("er.extensions.ERXOpenEditingContextLockTracesPassword")) {
     ERXStringHolder result = pageWithName(ERXStringHolder.class);
     result.setEscapeHTML(false);
     StringWriter sw = new StringWriter();
     PrintWriter pw = new PrintWriter(sw);
     pw.println("<pre>");
     pw.println(ERXEC.outstandingLockDescription());
     pw.println("</pre>");
     pw.println("<hr>");
     pw.println("<pre>");
     pw.println(ERXObjectStoreCoordinator.outstandingLockDescription());
     pw.println("</pre>");
     pw.close();
     result.setValue(sw.toString());
     return result;
   }
   return forbiddenResponse();
 }