vamshipasunuru1 commented on code in PR #20651:
URL: https://github.com/apache/hudi/pull/20651#discussion_r4701711123


##########
hudi-timeline-service/src/main/java/org/apache/hudi/timeline/service/RequestHandler.java:
##########
@@ -768,18 +779,35 @@ private boolean syncIfLocalViewBehind(Context ctx) {
       SyncableFileSystemView view = viewManager.getFileSystemView(basePath);
       synchronized (view) {
         HoodieTimeline localTimeline = view.getTimeline();
+        String timelineHashFromClient = getTimelineHashParam(ctx);
         // The final check already accepts a trailing clean with an otherwise 
matching timeline.
         // Other extensions still need a sync: restore may have deleted their 
extra instants.
-        if (!shouldThrowExceptionIfLocalViewBehind(localTimeline, 
getTimelineHashParam(ctx))) {
+        if (!shouldThrowExceptionIfLocalViewBehind(localTimeline, 
timelineHashFromClient)) {
           return false;
         }
         if (isLocalViewBehind(ctx)) {
           String lastKnownInstantFromClient = getLastInstantTsParam(ctx);
-          if (log.isInfoEnabled()) {
-            log.info("Syncing view as client passed last known instant {} as 
last known instant but server has the following last instant on timeline: {}",
-                lastKnownInstantFromClient, localTimeline.lastInstant());
+          String clientTimeline = basePath + ":" + timelineHashFromClient;
+          boolean hasLocalFallback = hasLocalFallback(ctx);
+          // The client timeline does not change. If a sync did not make the 
local view match it, one more sync cannot.
+          boolean unmatched = 
unmatchedClientTimelines.contains(clientTimeline);
+          if (!unmatched || !hasLocalFallback) {
+            if (log.isInfoEnabled()) {
+              log.info("Syncing view as client passed last known instant {} as 
last known instant but server has the following last instant on timeline: {}",
+                  lastKnownInstantFromClient, localTimeline.lastInstant());
+            }
+            view.sync();
+            unmatched = isLocalViewBehind(ctx) && 
shouldThrowExceptionIfLocalViewBehind(view.getTimeline(), 
timelineHashFromClient);

Review Comment:
   Done. `hasTimelineMismatch` now makes the check before the sync, after the 
sync, and after the listing. Each call gets the current timeline of the view. 
`shouldThrowExceptionIfLocalViewBehind` is now 
`matchesAfterRemovingTrailingClean`.



##########
hudi-timeline-service/src/main/java/org/apache/hudi/timeline/service/RequestHandler.java:
##########
@@ -768,18 +779,35 @@ private boolean syncIfLocalViewBehind(Context ctx) {
       SyncableFileSystemView view = viewManager.getFileSystemView(basePath);
       synchronized (view) {
         HoodieTimeline localTimeline = view.getTimeline();
+        String timelineHashFromClient = getTimelineHashParam(ctx);
         // The final check already accepts a trailing clean with an otherwise 
matching timeline.
         // Other extensions still need a sync: restore may have deleted their 
extra instants.
-        if (!shouldThrowExceptionIfLocalViewBehind(localTimeline, 
getTimelineHashParam(ctx))) {
+        if (!shouldThrowExceptionIfLocalViewBehind(localTimeline, 
timelineHashFromClient)) {
           return false;
         }
         if (isLocalViewBehind(ctx)) {
           String lastKnownInstantFromClient = getLastInstantTsParam(ctx);
-          if (log.isInfoEnabled()) {
-            log.info("Syncing view as client passed last known instant {} as 
last known instant but server has the following last instant on timeline: {}",
-                lastKnownInstantFromClient, localTimeline.lastInstant());
+          String clientTimeline = basePath + ":" + timelineHashFromClient;
+          boolean hasLocalFallback = hasLocalFallback(ctx);
+          // The client timeline does not change. If a sync did not make the 
local view match it, one more sync cannot.
+          boolean unmatched = 
unmatchedClientTimelines.contains(clientTimeline);
+          if (!unmatched || !hasLocalFallback) {

Review Comment:
   Done. When the client has a local fallback and its timeline is in the set, 
the server returns the 400 before the sync. The `unmatched` flag is gone. There 
is no change in behavior.



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