hgudladona commented on issue #13356:
URL: https://github.com/apache/hudi/issues/13356#issuecomment-2953422395

   would something like this in the ViewHandler work better? 
   
   ```
     private final ReadWriteLock viewLock = new ReentrantReadWriteLock();
   
   ...
   
     /**
      * Syncs data-set view if local view is behind.
      */
     private boolean syncIfLocalViewBehind(Context ctx) {
       // First check with read lock - allows concurrent reads
       viewLock.readLock().lock();
       try {
           if (!isLocalViewBehind(ctx)) {
               return false;  // View is in sync, no need for write lock
           }
       } finally {
           viewLock.readLock().unlock();
       }
   
       // Only if first check indicates sync is needed, get write lock
       viewLock.writeLock().lock();
       try {
           // Double check with write lock
           if (isLocalViewBehind(ctx)) {
               String basePath = 
ctx.queryParam(RemoteHoodieTableFileSystemView.BASEPATH_PARAM);
               SyncableFileSystemView view = 
viewManager.getFileSystemView(basePath);
               view.sync();
               return true;
           }
           return false;
       } finally {
           viewLock.writeLock().unlock();
       }
     }
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to