You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/08/30 23:39:09 UTC

[GitHub] [ozone] smengcl commented on a diff in pull request #3725: HDDS-7178. [Multi-Tenant] Use optimistic read in Ranger background sync

smengcl commented on code in PR #3725:
URL: https://github.com/apache/ozone/pull/3725#discussion_r959017966


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/multitenant/OMRangerBGSyncService.java:
##########
@@ -557,16 +558,29 @@ private void mtRangerPoliciesOpHelper(
   }
 
   /**
-   * Helper function to run the block with read lock held.
+   * Helper function to retry the block until it completes without a write lock
+   * being acquired during its execution. The block will be retried
+   * {@link this#MAX_ATTEMPT} times.
    */
-  private void withReadLock(Runnable block) throws IOException {
-    // Acquire authorizer (Ranger) read lock
-    long stamp = authorizerLock.tryReadLockThrowOnTimeout();
-    try {
+  private void withOptimisticRead(Runnable block) throws IOException {
+    // Acquire a stamp that will be used to check if a write occurred while we
+    // were reading.
+    // If a tenant modification is made while we are reading,
+    // retry the read operation with a new stamp until we are able to read the
+    // state without a write operation interrupting.
+    int attempt = 0;
+    boolean readSuccess = false;
+    while (!readSuccess && attempt < MAX_ATTEMPT) {

Review Comment:
   Let's use a different `MAX_ATTEMPT` constant to differentiate.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org