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

Move Permission Update due to DDL to HMS Post Event Listener

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • 2.1.0, 2.2.0
    • None
    • Sentry
    • None

    Description

      There was a code in MetastorePlugin that modified Sentry privileges on table Create/Drop and database Create/Drop. As part of Sentry HA work we moved all this logic from Sentry plugin to be driven by notifications which required the extra synchronization between HMS and Sentry.

      It should be possible to do permission changes in the post event listener itself to avoid blocking for Sentry. This requires some experiments though because it may cause strange artifacts since at the time these DDL operations are done Sentry may not be aware of the current state - for example you may try to change permissions of a table that Sentry doesn’t know about, which seems to be OK.

      This update will have the following benefits:

      * HMS waits on Sentry polling HMS update takes 0.5 to 1 second. This update will remove this delay
      * Sentry knows every DDL update, and therefore can update permission correctly. In current approach using notification processing, Sentry could miss updates if full snapshot is fetched from HMS, and permission is not updated correctly. In the case of table rename, when mission DDL update event because of full snapshot, sentry will not move the permissions associated with old table to the new table. And the authorization on queries on the renamed table will fail.
      

      The proposed approach is:

      1) Add the permission update in SentryPolicyStoreProcessor.sentry_notify_hms_event() through SentrySyncHMSNotificationsPostEventListener for create/drop/alter table, create/drop database commands. This is synchronous processing.
      2) Remove the permission update from NotificationProcessor.processNotificationEvent() for create/drop/alter table, create/drop database commands. 
      3) Remove the blocking of HMS in SentrySyncHMSNotificationsPostEventListener for Sentry fetching notification events asynchronously from HMS for create/drop/alter table, create/drop database commands. The reason is that now the permission is updated through SentrySyncHMSNotificationsPostEventListener. Therefore, there is no need for HMS to wait for Sentry fetching those notification events. 
      

      Without this approach, the DDL operation take at least 500 to 1000 milliseconds. It is easy for HMS to encounter SyncTimeoutException when it takes long time for Sentry to get full snapshot or fetch notification events. Many users choose to remove the post event listener in configuration (HMS not waiting for Sentry fetching notification events asynchronously) to get rid of this exception. Users cannot take this workaround if they want owner privilege enabled.

      This approach makes DDL operation in HMS independent from Sentry fetching full snapshot or notification events, and reduces the DDL operation delay significantly. With this approach, the DDL operation is in the range of few milliseconds. This approach fixes the timeout issue once for all. And users can get rid of timeout issue and enable owner privilege at the same time

      Attachments

        1. SENTRY-2300.001.patch
          63 kB
          Na Li
        2. SENTRY-2300.002.patch
          72 kB
          Na Li

        Issue Links

          Activity

            People

              Unassigned Unassigned
              linaataustin Na Li
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: