Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Selenium Grid availability - Clean up thread doesn't clean sessions with null external key #6771

Closed
lukeis opened this issue Mar 4, 2016 · 4 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 6771

 I found in the cleanup thread, there are some slots are never free. After set breakpoint
in the cleanup thread, I found the root cause:
Sometimes, the code throws out IllegalStateException in DefaultRemoteProxy class’ beforeRelease
method.
if (session.getExternalKey() == null) {
      throw new IllegalStateException(
          "cannot release the resources, they haven't been reserved properly.");
}
For this slot, it should be cleaned up in the registry and get free for another session.
However, it’s not handled in Cleanup thread. Then I can see its inactivity time will
last very long, in my several watches, it reached 1 hour.

Solution: Continue cleaning up for test slot with “ExternalKey is null” situation to
free it.
------------------------------------------ BaseRemoteProxy.java----------------------------------------------------------------------
private void cleanUpSlot(TestSlot slot) {
      TestSession session = slot.getSession();
      if (session != null) {
        long inactivity = session.getInactivityTime();
        boolean hasTimedOut = inactivity > timeOutMs;
        if (hasTimedOut) {
          if (!session.isForwardingRequest()) {
            log.logp(Level.WARNING, "SessionCleanup", null,
                "session " + session
                    + " has TIMED OUT due to client inactivity and will be released.");
            try{
              ((TimeoutListener) proxy).beforeRelease(session);
            }catch(IllegalStateException ignore){
            log.log(Level.WARNING, ignore.getMessage());
         }
            registry.terminate(session, SessionTerminationReason.TIMEOUT);
          }
        }

Reported by shijunjuan on 2013-12-26 07:50:33

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2013-12-27 10:01:03

  • Labels added: Component-Grid

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

diff --git a/java/server/src/org/openqa/grid/internal/BaseRemoteProxy.java b/jav
index c103f9e..992a30c 100644
--- a/java/server/src/org/openqa/grid/internal/BaseRemoteProxy.java
+++ b/java/server/src/org/openqa/grid/internal/BaseRemoteProxy.java
@@ -310,7 +310,12 @@ private void cleanUpSlot(TestSlot slot) {
             log.logp(Level.WARNING, "SessionCleanup", null,
                 "session " + session
                     + " has TIMED OUT due to client inactivity and will be rele
-            ((TimeoutListener) proxy).beforeRelease(session);
+            try{
+               ((TimeoutListener) proxy).beforeRelease(session);
+            }catch(IllegalStateException ignore){ //handle sessions with illega
+                log.log(Level.WARNING, ignore.getMessage());
+            }
+
             registry.terminate(session, SessionTerminationReason.TIMEOUT);
           }
         }

Reported by shijunjuan on 2014-01-29 06:42:20

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This issue was closed by revision 6c14f1417552.

Reported by barancev on 2014-06-30 22:12:11

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:21:53

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant