Uploaded image for project: 'Sentry (Retired)'
  1. Sentry (Retired)
  2. SENTRY-1759

UpdatableCache leaks connections

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.8.0, 2.0.0
    • 1.8.0, 2.0.0
    • Sentry
    • None

    Description

      In UpdatableCache.loadFromRemote():

        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;
        }
      

      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.

      Attachments

        1. SENTRY-1759.001.patch
          3 kB
          Alex Kolbasov

        Issue Links

          Activity

            People

              akolb Alex Kolbasov
              akolb Alex Kolbasov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: