Alexander Kolbasov created SENTRY-1759:
------------------------------------------

             Summary: UpdatableCache leaks connections
                 Key: SENTRY-1759
                 URL: https://issues.apache.org/jira/browse/SENTRY-1759
             Project: Sentry
          Issue Type: Bug
          Components: Sentry
    Affects Versions: 1.8.0
            Reporter: Alexander Kolbasov
            Assignee: Alexander Kolbasov
            Priority: Critical
             Fix For: sentry-ha-redesign


In UpdatableCache.loadFromRemote():

{code}
  private Table<String, String, Set<String>> loadFromRemote() throws Exception {
    Table<String, String, Set<String>> tempCache = HashBasedTable.create();
    String requestor;
    requestor = UserGroupInformation.getLoginUser().getShortUserName();

    final SentryGenericServiceClient client = getClient(); // <-- Client created
    final Set<TSentryRole> tSentryRoles = client.listAllRoles(requestor, 
componentType);

    for (TSentryRole tSentryRole : tSentryRoles) {
      final String roleName = tSentryRole.getRoleName();
      final Set<TSentryPrivilege> tSentryPrivileges = 
client.listPrivilegesByRoleName(requestor, roleName, componentType, 
serviceName);
      for (String group : tSentryRole.getGroups()) {
        Set<String> currentPrivileges = tempCache.get(group, roleName);
        if (currentPrivileges == null) {
          currentPrivileges = new HashSet<>();
          tempCache.put(group, roleName, currentPrivileges);
        }
        for (TSentryPrivilege tSentryPrivilege : tSentryPrivileges) {
          
currentPrivileges.add(tSentryPrivilegeConverter.toString(tSentryPrivilege));
        }
      }
    }
    return tempCache;
  }
{code}

As you can see, the client is never closed, so on each timer iteration we are 
leaking one connected client. This may quickly exhaust server connection queue.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to